Move new pages to top of sitemap page tree when created

Permalink
A client is using a series of subpages as a means of adding news articles. They would like the newly added pages to appear at the top of the sitemap tree rather than the bottom when they are added.

I can't seem to find the methods or events used to control page order within the sitemap. I would imagine that it wouldn't be difficult to extend the page creation procedure to fetch the page id after creation and then automatically request that the new page be moved to the top of the tree.

Any insights would be most appreciated!

 
mesuva replied on at Permalink Reply
mesuva
This sounds like you need to hook into one of concrete5's events. I haven't done this myself (yet), but I think have a look at:

http://www.concrete5.org/documentation/developers/system/events/...
The on_page_add event looks like what you are after.

In the API http://www.concrete5.org/api/ in the Page class, there appears to be a move function. Perhaps have a look at that.
jordanlev replied on at Permalink Best Answer Reply 1 Attachment
jordanlev
And there's a handy "movePageDisplayOrderToTop()" function in the page object, so this is fairly straightforward. Attaching a package you can install that will do this.
mesuva replied on at Permalink Reply
mesuva
How did I miss that function!

Nice work on that package, couldn't get any tidier. Marketplace?
dimunation replied on at Permalink Reply
Can't believe I missed this function as well. This was exactly what I was looking for, and the simplicity of the solution you posted is very impressive.

A nice extension of the attached example would be the addition of a custom page attribute to control whether subpages are added to the top or bottom of the list. I might take a crack at this if the client desires some additional functionality. I'll post any updated versions to this thread.

Thanks again!
jordanlev replied on at Permalink Reply
jordanlev
I'm curious: what is the reason your client wants this feature? I've never personally run into a situation where it was necessary because I just use the page list block and tell it to sort items "most recent first". Wondering if I'm missing something...
dimunation replied on at Permalink Reply
They have a dedicated news section with a large number of subpages. The page list block will sort by most recent first, but its helpful to have the sitemap order match the page list block order. That, and they don't need to scroll down to the bottom to find the most recent additions. I think its mostly a matter of personal preference.
jordanlev replied on at Permalink Reply
jordanlev
Ah, I get it -- it's so the dashboard sitemap is easier to deal with, not for any particular front-end functionality. Makes sense to me.