Nico Knoll Posted May 3, 2012 Share Posted May 3, 2012 Hi, is there a way to pin a page to the top of the page tree? I mean that every other page is sorted by date but this one. / Nico Link to comment Share on other sites More sharing options...
diogo Posted May 3, 2012 Share Posted May 3, 2012 You can do it on the template with $array->shift() echo $array->shift()->title; foreach($array->find("sort=date") as $item) echo $item->title; edit: Or, if you want the complete array: $first = $array->shift(); $final = $array->find("sort=date")->prepend($first); 1 Link to comment Share on other sites More sharing options...
ryan Posted May 4, 2012 Share Posted May 4, 2012 You could also create and add a checkbox field to your template(s) and call it something like "sticky". When a page has the box checked, it will stick to the top of the list. Then when you perform the call to load your pages, sort by -sticky first, then by -date, i.e. $pages->find("parent=/news/, sort=-sticky, sort=-date"); Link to comment Share on other sites More sharing options...
Nico Knoll Posted May 5, 2012 Author Share Posted May 5, 2012 Well, thank you for the code but I meant in the backend page tree. (I would need a module I guess) Link to comment Share on other sites More sharing options...
Nico Knoll Posted May 9, 2012 Author Share Posted May 9, 2012 So.... I guess I have to write a module for this? Link to comment Share on other sites More sharing options...
ryan Posted May 9, 2012 Share Posted May 9, 2012 I think so. Parent pages don't currently support multiple built-in sort fields for children (like in the API), so it would have to be one sort field or the other. That makes it difficult to pin a page in the admin, even if you can do it easily in your own site. Down the road a bit I think we'll have to add multiple sort fields, which would solve this pretty easily. Link to comment Share on other sites More sharing options...
horst Posted October 7, 2013 Share Posted October 7, 2013 I think so. Parent pages don't currently support multiple built-in sort fields for children (like in the API), so it would have to be one sort field or the other. That makes it difficult to pin a page in the admin, even if you can do it easily in your own site. Down the road a bit I think we'll have to add multiple sort fields, which would solve this pretty easily. Is there something new to this, since this thread is over a year old? Well, thank you for the code but I meant in the backend page tree. (I would need a module I guess) @Nico: if you have done it, - how have you done it? In the backend I want to have pagetree children sorted by a archive number descending, but also want to be able to manually drag some pages to the top of the tree. All new childpages will be created via API bootsstrapped script. If it is possible with API to add each of them to the top of the page tree, this would allready solve my needs. Any pointers for that? Link to comment Share on other sites More sharing options...
Chris Ernovsky Posted May 8, 2020 Share Posted May 8, 2020 On 5/4/2012 at 8:56 PM, ryan said: You could also create and add a checkbox field to your template(s) and call it something like "sticky". When a page has the box checked, it will stick to the top of the list. Then when you perform the call to load your pages, sort by -sticky first, then by -date, i.e. $pages->find("parent=/news/, sort=-sticky, sort=-date"); @ryan, I know it's an ancient thread, but I'm slowly finishing my first public/client site with PW and this "sort=-sticky" trick has just blown my mind... ? I've got few crossing loops with different layouts and was trying to implement some kind of clever sticky mechanism onto all my find/sort structures. I was almost there with checkbox conditions but decided to look around here for a little help. Found this thread, adjusted and put your suggestion into my project and... started to dance and scream. ? PW is PHENOMENAL! I'm learning PW API for few weeks intensively and I'm more and more thrilled. Thank You and all Devs so much for this wonderful CMF/CME! 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now