Page 1 of 1
Navigator Sort Order
Posted: Tue Dec 12, 2023 5:08 pm
by WDJames
Hello All,
I'm using the Navigator module to show a list of child pages. I've looked at the parameters but I can't seem to find a way to sort the pages on the front end. I know that on the backend the latest added page is at the bottom of the list which is fine but I need the newest to be displayed at the top. Any one have any ideas?
Thanks,
James
Re: Navigator Sort Order
Posted: Tue Dec 12, 2023 5:46 pm
by DIGI3
Navigator uses the order assigned in the backend, so the simplest option is to reorder the pages as desired (there's a drag and drop utility for doing this).
If that's not a desired option you can sort the $data array in your Navigator template before the foreach. See
https://cmscanbesimple.org/blog/sort-array-modifier for inspiration.
You can also use javascript/jquery to sort the output, which is handy if it's only a specific part of the menu you want to sort.
Re: Navigator Sort Order
Posted: Tue Dec 12, 2023 6:05 pm
by WDJames
Hi Digi,
Thanks for getting back to me.
Navigator uses the order assigned in the backend, so the simplest option is to reorder the pages as desired (there's a drag and drop utility for doing this).
I'm afraid that this can't work as there are currently 30 or so pages and there are more to be added.
I think I'll explore this option as I can't really use javascript/jquery due to the potential number of items.
Just for added context, the pages are Case Studies which are divided into 2 categories (commercial, domestic). I could just use a LISE instance called Case Studies and use the category field definition but as far as I'm aware, there isn't a way to include the category on the automatically generated url of an LISE item.
Thanks,
James
Re: Navigator Sort Order
Posted: Tue Dec 12, 2023 6:23 pm
by DIGI3
I should add, if it's simply reversing the order, you can try |@array_reverse on the $data array. It may require permissive_smarty to be enabled in your config.php.
Re: Navigator Sort Order
Posted: Tue Dec 12, 2023 6:28 pm
by WDJames
Hi Digi,
I should've checked for replies earlier. I've just created a reverse_array modifier based on the sort_array modifier you suggested. I can confirm that |@array_reverse works without enabling permissive_smarty.
Thanks again for your help.
James