I want to have a user selectable option to sort sub pages alphabetically and if not sorted alphabetically then use the manual sort order. So in my template I want to say pages.children.sortBy(SORT_OPTION, SORT_DIRECTION)
, where SORT_OPTION and SORT_DIRECTION are variables set by reading the fields for the parent page. I can sort alphabetically with ‘title’, but what do I do if I don’t want to sort alphabetically? I need a default or dummy parameter to pass into sortBy. I have tried ‘index’, ‘default’, ‘none’, null… none of them work. I tried ‘sort’, which I think works for sorting some things, but in this case I got an error “Missing argument 1 for PageAbstract::sort()” and all my pages were set to invisible! This must be a bug.
I suggest to solve this with an if-else statement depending on the value of the field, so that if the user wants to use manual sorting, you don’t use the sort method.
Actually I figured out I can use ‘diruri’ for the sort field. Nicer than having to make different collections of pages and using an if statement to choose between them.
I noticed that my folders got a bunch of crazy dashes as a result of my experimentation, like 1----projectA, —projectB, --projectC, 2----projectD, etc. Must be due to that glitch when I tried sorting by ‘sort’.
I’m looking for a solution for manual sorting. For the $hasPrev function.
Can you explain what your solution is?How does ‘diruri’ help with this?
@Vivo: Check out this solution: Navigate into a collection with hasNext/hasPrev