Thanks John, just wondering how I can use this and what it does?
Will I need to change the column names? And how do I attach this to my extent code. As mentioned, I already have the articles showing, I just need to limit what is showing and potentially, display them by the latest date (last_modified) column.
Have you managed to solve your problem? If so can you post your solution?
The function I supplied was just to show how to iterate an Object and to add results to an array. It was not just to copy and paste into your script.
If you haven’t managed to sort your problem then what I often do is make a verbose solution and then try to tidy the script and make it more readable (for future debugging).
Ha. You’d now if I found a solution I’d be telling everyone
Spent hours last night trying to fix this, open a new account over on the stackoverflow, here what I was upto last night if you want to get involved ha. link to thread
Thanks, Barry
PS. I’ve also been in touch with the support team today who run the admin on the CMS:
me: Each article page shows all the latest articles in the footer. The problem is, they all show. I need to limit the $children to about 6 and show them in ascending order based on the last_modified column from the navigation table. them: Personally I prefer a navigation-based template but with additional db-writing functionality to enable custom sorting with whatever creterias.
me: I don’t have access directly to the SQL else things would be a lot easier. them: You have – but it isn’t a good idea. Please never try to write to navigation-db – this could easily destroy consistence of navigation completely.
More information from support:
Navigation-Api by default sorts after parent_id, position, date.
If this is not enough to solve your problems you should sort an array with for example http://php.net/manual/en/function.uasort.php and related custom sort functions.
I am not sure, whether a Navigation Subtree is sortable by these functions but anyway you can manage a custom array filled before with page_id and date_modified.
After much testing and talking, we needed to put the result into a separate array which we then sorted. I also created a new column, similar to last_modified though with a fixed date ext_column_4, this was mainly just for a visual so the articles don’t get republished when I regenerate the pages and site
I think I explained this correctly. Nice to hear any feedback or views based on this. For the record, I never could sort the xml data and sorted everything from the main navigation. $topPages are the top level pages from the database I think, the children are the sub pages attached to this.