Jump to content

Adding new page to top of list of existing pages


Recommended Posts

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
Link to comment
Share on other sites

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


Link to comment
Share on other sites

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...