Sort pagelist by Name
Permalink
I currently have a page list displaying 10 people per page in display order. I need this to display people in alphabetical order a-z on the second (surname) name (Names of the people are page names). Somehow I need to sort the array before I execute this line:
The sorting options in the concrete5 core include
I need a sortBySurname() function!
$pages = $pl->getPage();
The sorting options in the concrete5 core include
$pl->sortByName(); $pl->sortByNameDescending();
I need a sortBySurname() function!
Currently have 120+ names which is likely to grow.
Is there no way of sorting the pagelist by the second word (surname) in the page name field?
Is there no way of sorting the pagelist by the second word (surname) in the page name field?
you can use the sort function to inject some custom SQL, but I'd strongly recommend to avoid that. You'll use full table scans for every query you run. As john wrote, use an attribute to keep things clear and easy to handle, especially if you'll have more data.
Thanks guys, I've decided to just keep it simple and use the sortByName() function. Anything custom in the future Imma go the attribute route.
For future reference, By "big and slow" I mean thousands, not hundreds.
The actual performance depends on your server.
The actual performance depends on your server.
For Firstname/Surname you will need attributes to hold them and then sort by the attribute.
(If you have a big list, it may be a lot slower)
Or you could have a look at UberList with MagicData.