Sort pages by index

Hi,

correct me if I’m wrong, but I noticed there was a feature that you can edit the order of pages and if they’re visible or invisible with drag and drop (I would post an image if I could). Shouldn’t I be able to access this order somehow and then use it with $pages->sortBy() ? I haven’t found anything on this at all. Do I have to manually create an order_by field?

Thanks for help in advance.

Peter

If pages are visible they have a prepended number, in this case their default sort order is according to this number. What the dragging and dropping to change the order does, is change the prepended numbers. That is, this order is then visible to Kirby and you don’t need to sort the pages by any other field.

You can also sortBy() any field, that would of course require such a sort field in the text files, as you said, otherwise it doesn’t make sense.

I’m not sure what the default sorting order of invisible pages is, but I don’t think that dragging them around in the panel makes any difference because no information is added to the folders or files in that case.

Hi,

thanks for your help. So I can only order pages that are visible?
I’m actually looking for some way to create models (pages) that aren’t visible in the navigation or accessible through typing in the URL. I wish to use these in my template to render complex pages. Is there any functionality which would allow me to do this?

For example I have some pages called "home-section/-section/section.txt". These sections would be looped through on the home page to create sections, but I don’t wish for the pages themselves to be visible through http://website.com/home-section/-section

Thanks again, I appreciate the info.

Peter

OK, maybe this is a misunderstanding of what visible and invisible means. Any page that you create, no matter if visible or invisible, is accessible via its URL. The way to prevent direct access is to redirect these section pages to the homepage or an error page, e.g. via the default.php template or any other template that you create for this purpose, or by access protection.

So for sections on your start page, you could still make your pages visible for sorting purposes.

Ah okay, I see. Thanks for clearing that up.