Jump to content


Photo

Pin page to top of page tree


  • Please log in to reply
5 replies to this topic

#1 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 644 posts
  • 235

  • LocationBerlin, Germany

Posted 03 May 2012 - 04:21 PM

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

#2 diogo

diogo

    Hero Member

  • Moderators
  • 2,000 posts
  • 1078

  • LocationPorto, Portugal

Posted 03 May 2012 - 06:23 PM

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);


#3 ryan

ryan

    Hero Member

  • Administrators
  • 5,773 posts
  • 3120

  • LocationAtlanta, GA

Posted 04 May 2012 - 01:56 PM

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");


#4 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 644 posts
  • 235

  • LocationBerlin, Germany

Posted 05 May 2012 - 11:39 AM

Well, thank you for the code but I meant in the backend page tree. (I would need a module I guess)

#5 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 644 posts
  • 235

  • LocationBerlin, Germany

Posted 09 May 2012 - 12:39 PM

So.... I guess I have to write a module for this? :)

#6 ryan

ryan

    Hero Member

  • Administrators
  • 5,773 posts
  • 3120

  • LocationAtlanta, GA

Posted 09 May 2012 - 12:52 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users