How Do You Set The Starting Page Using The Pages Module Structure Function

b1gw0rm - 2 weeks ago

How would I modify the example code from the pages module documentation to generate the navigation starting at a page with a slug of "education/staff" for example?

{{ structure(template.page)
    .linkAttributesDropdown({'data-toggle': 'dropdown'})
    .listClass('nav navbar-nav navbar-right')
    .childListClass('dropdown-menu')
    .render()|raw }}

Answer

william - 2 weeks ago

Change the list tag to something else than unordered list: {{ structure().list_tag('dl')|raw }} Change the list tag to something else than unordered list: {{ structure().list_tag('dl')|raw }}

Change list element

{{ structure().link_tag('dt')|raw }}

Show children of only a specific page

{{ structure().root('/my-page')|raw }} or page-id {{ structure().root('9')|raw }}

Set class for the element with children

{{ structure().dropdown_class('has-children')|raw }}

Set a class to every li item:

{{ structure().item_class('has-children')|raw }}

Set a class to the link

{{ structure().link_class('my-class')|raw }}

Add a title attribute to the link

{{ structure().link_attributes({'title':'Title attribute'})|raw }}

william - 2 weeks ago

Change the list tag to something else than unordered list: {{ structure().list_tag('dl')|raw }} Change the list tag to something else than unordered list: {{ structure().list_tag('dl')|raw }}

Change list element

{{ structure().link_tag('dt')|raw }}

Show children of only a specific page

{{ structure().root('/my-page')|raw }} or page-id {{ structure().root('9')|raw }}

Set class for the element with children

{{ structure().dropdown_class('has-children')|raw }}

Set a class to every li item:

{{ structure().item_class('has-children')|raw }}

Set a class to the link

{{ structure().link_class('my-class')|raw }}

Add a title attribute to the link

{{ structure().link_attributes({'title':'Title attribute'})|raw }}

william - 2 weeks ago

So the answer is : {{ structure().root('/my-page')|raw }}

b1gw0rm - 2 weeks ago

I've also found that you can do this:

{{ structure('education/staff')|raw }}

Are you looking through source code to find this information? I haven't seen anything in the documentation referencing .root like you mentioned {{ structure().root('/my-page')|raw }}.

Thanks for the information.

ryanthompson - 2 weeks ago

@b1gw0rm it's doc'd that you can pass any options with chained methods like that but @william likely just saw root (which is docd as an argument) get's pushed into options anyways as do ALL plugin option scenarios like this: https://pyrocms.com/documentation/pages-module/latest#usage/plugin/structure/available-options