Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Page ListChildren with hidden in navigation filter in sightly

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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 !

View solution in original post

2 Replies

Avatar

Level 10

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.

Avatar

Correct answer by
Community Advisor

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 !