Jump to content

What is it that determines the sort position of new pages?


Robin S
 Share

Recommended Posts

I have just created a new page "Sponsors" under "Home":

2017-10-11_135608.png.5dea0cb52dd52458e800f9104644d639.png

My question is, how does PW decide that it is going to place this new page between "Form Builder" and "Page Not Found"? Why not at the top or bottom of the existing pages? When I created "Monitoring" and "Groups" the situation was the same and I sorted them manually.

This has been bugging me for a while, and I can't see what the rhyme or reason is. First thought was that "pages with system templates get sorted last", but that doesn't hold up because Form Builder uses a system template and Page Not Found does not.

Edit: in case it's relevant, the "Tools", "Instructions" and "Form Builder" pages are pre-existing pages that are included in my custom site profile.

Link to comment
Share on other sites

@monchu, thanks for the reply. It's not quite what I'm asking about - it's the default sort order I'm interested in and why a new page would be inserted in the middle of existing pages.

I did manage to figure some stuff out...

Firstly, it seems the 404 page, Admin and Trash are always sorted last. There's no changing that, which is fine.

Also, looking at the "sort" column of the "pages" table in the DB it looks like there were gaps in the sequence of sort values of pages under Home. Because of those gaps and also the fact that some of the pages that are part of my site profile happened to have high sort values, new pages were being inserted above them in the tree.

So I fixed the gaps with...

$home = $pages->get('/');
$pages->sort($home, true); // re-build sort values for children of $home, removing duplicates and gaps

...and then I manually gave high sort values to any pages that I want to keep at the bottom of the tree (but still above 404, Admin, etc, as per the above)...

$p = $pages(1016); // the Form Builder page
$pages->sort($p, 99); // set the sort value to a high number

Now new pages are going just where I want them. :)

  • Like 6
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
 Share

  • Recently Browsing   0 members

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