Jump to content

Recommended Posts

Posted

Hi all,

I wonder if PW allows for a custom sort order of pages? I would like to render my page tree custom sorted for a mobile menu, e.g. not in "reverse sort order" or "sorted by date" and so on but completely customized.

My current page tree in the admin looks as follows (numbers are page ids):

/

|- page 1006

|- page 1058

|- page 1062

But for my mobile menu I try to render the following order:

/

|- 1062

|- 1006

|- 1058

$entries = $pages->get("id=1|1006|1058|1062, sort=??");

Any ideas how to achieve this?

Many thanks!

Posted

If you have set the sort order to manually in the childrens parent site, you can use "sort=sort" or "sort=-sort" in the selector.

(Hope this is what you are asking for??)

Posted

Hello Horst,

unfortunately this is not what I meant. The page tree in the admin needs to remain as it is (as it makes for the desktop navigation). I need a custom order ("sorting") only for the mobile navigation.

In other words: I need to render the pages in a custom order different to what I have in the admin.

Difficult to explain in English. Hope one can get it ...

Posted

I would create a multiple select page field on the template that you are using to control your navigation. Either point the page field to the parent of your navigational elements or use a asm field and filter by template. Then instead of performing your find on the pages you will just load the field. 

<?php 

$navigation_elements = $pages->get('/setting-page/')->navigation;

foreach($navigation_elements as $elem){
  //nav code here
}

?>
  • Like 5
Posted

Let say you have these pages in your tree:

Products (1005)

|- page 1006

|- page 1058
|- page 1062
 

You could add a field of the type Page (FieldtypePage) with a name "mobile_sort" or something alike. make sure you can select multiple pages, and it will list the children from the Products (1005) page (or whatever your parent page is named).

Then add this field to the Products page template. Next edit the Product page and select all the children and sort them accordingly for mobile.

You could then create a navigation for your mobile listing all pages attached to the "mobile_sort" field.

Another way i think will work is to use the sorting of the mobile_sort field in your selector. 

sort=mobile_sort.sort
  • Like 5

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
×
×
  • Create New...