Have you seen our video tutorials? Check 'em out!

Pages plugin - structure

kiltedup - 1 month ago

Hi,

Trying to use the Pages plugin function 'structure'.

Issue I'm having is that regardess of what I pass as the option for 'root', the output is the entire page structure of the site.

End result I'm looking for - say you are on a child page, structure will return all other child pages of the current pages parent.

Anyone used this successfully?

TIA

adnan - 1 month ago

If I understood your question correctly, try the parent option,

{{ structure().parent(page().parent).listClass('nav navbar-nav navbar-right').render()|raw }}

ryanthompson - 1 month ago

@adnan there is also a root option which you can send a page instance / path string: https://github.com/anomalylabs/pages-module/blob/master/src/Page/Command/RenderNavigation.php#L51

Waiting to release pages 2.2 in order to write docs on it..

kiltedup - 1 month ago

Thanks for the replies.

I was using the root option with a path string - turned out the issue was simply that there was no leading '/' on the string. Without that the entire tree was returned.