Page ListChildren with hidden in navigation filter in sightly | Community
Skip to main content
Level 2
April 15, 2019
Solved

Page ListChildren with hidden in navigation filter in sightly

  • April 15, 2019
  • 2 replies
  • 2173 views

Hi

I am using the below code snipped to iterate over my pages and list out the children

<template data-sly-template.descendants="${@ page}">
  ${page.title}
  <ul data-sly-list.child="${page.listChildren}">
       <li data-sly-call="${descendants @ page=child}"></li>
  </ul>
</template>
<div data-sly-call="${descendants @ page=currentPage}" data-sly-unwrap></div>

But ${page.listChildren} gives all the pages including the pages that are hidden in the Navigation too,

is there way to filter the pages that are hidden in navigation with in Sightly?

Please help

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Ravi_Pampana

Hi,

Please use query builder to fetch the child pages in java and iterate the list of pages in sightly. Iterating over list in sightly is very simple and you can also bind the resources returned from query builder to sling models.

Using query builder, you can fetch pages under a page (using path property) and exclude pages using property field (property.operation=equals for checking value equals, property.operation=not for property not present, property.operation=like for property contains the value) and using property, you can list the pages of specific resourcetypes.

Use p.limit=-1 to list all the results (unless it will fetch only 10 results by default) and also add p.guessTotal=true. Also create oak index so that query builder runs fine and wont slow down the instance if the pages are very large.

Please check Query Builder API for more details

Hope this helps !

2 replies

smacdonald2008
Level 10
April 15, 2019

Build a Java backend Query pages where you are interested in. Exclude the pages you do not want. That way - you have much better control over your data.

Ravi_Pampana
Community Advisor
Ravi_PampanaCommunity AdvisorAccepted solution
Community Advisor
April 15, 2019

Hi,

Please use query builder to fetch the child pages in java and iterate the list of pages in sightly. Iterating over list in sightly is very simple and you can also bind the resources returned from query builder to sling models.

Using query builder, you can fetch pages under a page (using path property) and exclude pages using property field (property.operation=equals for checking value equals, property.operation=not for property not present, property.operation=like for property contains the value) and using property, you can list the pages of specific resourcetypes.

Use p.limit=-1 to list all the results (unless it will fetch only 10 results by default) and also add p.guessTotal=true. Also create oak index so that query builder runs fine and wont slow down the instance if the pages are very large.

Please check Query Builder API for more details

Hope this helps !