Jump to content

Recommended Posts

Posted

I'm pretty sure there is a simple way to configure PW to add new pages to the top of the list of already existing pages instead of the bottom - I simply can't find how and where to change the default setting.
Thank you for your help!

  • Like 1
Posted

You can define the sort settings for children in the parent's settings family tab. There you can select "created" and "reverse sort order"

  • Like 1
Posted

Oh, I see. I'll give it a try..
I thought this option would take away the manual sorting option.
Thank you!

Posted

@rsi you can use $pages->sort() to set the sort value of the new page to zero after it is added, and that will make it appear at the top of its siblings but still be manually sortable.

In /site/ready.php:

$pages->addHookAfter('added', function(HookEvent $event) {
	$pages = $event->object;
	// The page that is being added
	$page = $event->arguments(0);
	// If the page passes some kind of test
	if($page->template == 'news_item') {
		// Set the sort value for the new page to zero (sibling sort will be automatically adjusted)
		$pages->sort($page, 0);
	}
});

 

  • Like 4
  • Thanks 1
Posted

Oh - WOW - Just as expected with processwire - there's a ton of options to get what I want!!
Thank you

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...