In CMSMS 2.1.2:
Site will add 50 to 60 articles per year in several areas of the site... is it possible to set Navigator to list menu items last to first instead of the default first to last, so that the last item added is always at the top of the list?
Navigator: is there a simple way to reverse the array?
-
- Forum Members
- Posts: 247
- Joined: Sun Oct 28, 2007 4:14 am
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Navigator: is there a simple way to reverse the array?
Yes....
{$nodes=array_reverse($nodes)}
directly before the foreach loop should reverse the list of everything.
You may need to enable permissive smarty in the config.php
(it's in the config reference doc).
{$nodes=array_reverse($nodes)}
directly before the foreach loop should reverse the list of everything.
You may need to enable permissive smarty in the config.php
(it's in the config reference doc).
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
-
- Forum Members
- Posts: 247
- Joined: Sun Oct 28, 2007 4:14 am
Re: Navigator: is there a simple way to reverse the array?
Thankyou.
As a complete amateur, I can insert the smarty code into the template, and I have enabled the permissive smarty in config.php which allows the template to load.
But I have no idea how to configure the reverse array function so that Calguy's code actually does anything.
I have in Navigator
{Navigator start_level="4" collapse="1" ... ion test"}
which works as intended, except it does not reverse the array.
As a complete amateur, I can insert the smarty code into the template, and I have enabled the permissive smarty in config.php which allows the template to load.
But I have no idea how to configure the reverse array function so that Calguy's code actually does anything.
I have in Navigator
{Navigator start_level="4" collapse="1" ... ion test"}
which works as intended, except it does not reverse the array.
Re: Navigator: is there a simple way to reverse the array?
Code: Select all
...
{if !isset($depth)}{$depth=0}{/if}
{if isset($nodes)}{strip}
{$nodes=array_reverse($nodes)}
<ul>
{foreach $nodes as $node}
{if $node->type == 'sectionheader'}
...
-
- Forum Members
- Posts: 247
- Joined: Sun Oct 28, 2007 4:14 am
Re: Navigator: is there a simple way to reverse the array
Thank you all. It works when I have this as the last few lines of the Navigator template
Code: Select all
{/strip}{/function}
{$nodes=array_reverse($nodes)}
{if isset($nodes)}
{Nav_menu data=$nodes depth=0}
{/if}
Last edited by Andrew Prior on Tue Apr 05, 2016 9:21 pm, edited 1 time in total.
Re: Navigator: is there a simple way to reverse the array?
Better change order of those two lines for obvious reason:Andrew Prior wrote:Thank you all. It works when I have this as the last few lines of the Navigator template
Code: Select all
{/strip}{/function} {$nodes=array_reverse($nodes)} {if isset($nodes)} {Nav_menu data=$nodes depth=0} {/if}
Code: Select all
{/strip}{/function}
{if isset($nodes)}
{$nodes=array_reverse($nodes)}
{Nav_menu data=$nodes depth=0}
{/if}
-
- Forum Members
- Posts: 247
- Joined: Sun Oct 28, 2007 4:14 am
Re: Navigator: is there a simple way to reverse the array?
Ta... How can I apply [Solved] to the original post? It doesn't seem to let me edit it?