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
BedrockMission!

Learn More

View all

Sign in to view all badges

Page ListChildren with hidden in navigation filter in sightly

Avatar

Avatar
Validate 1
Level 2
ybharath264
Level 2

Likes

3 likes

Total Posts

17 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
ybharath264
Level 2

Likes

3 likes

Total Posts

17 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
ybharath264
Level 2

15-04-2019

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

183 likes

Total Posts

233 posts

Correct Reply

70 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

183 likes

Total Posts

233 posts

Correct Reply

70 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile
Ravi_Pampana
MVP

15-04-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 !

Answers (1)

Answers (1)

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

15-04-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.