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

How to search for only pages which are published using querybuilder?

Avatar

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile
TB3dock
Level 4

22-04-2021

We are trying to get json from components of specific pages to render on client.  We can individually lookup each required page by its template type:

 

path=/content/mysite/en/
type=cq:page
1_property=jcr:content/cq:template
1_property.value=/conf/mysite/settings/wcm/templates/my-page-template
some othe properties to narrow down the required page.

 

Then we can do another query to retrieve all its children, and iterate through them looking for the 2 components we required, and then copying each property to a model for later conversion to json.

 

The problem is that the first query returns unpublished pages, which the user should not yet be able to see.

How do we only return published content?

 

The page only seems to have 3 properties:

1) jcr:created

2) jcr:createdBy 

3) jcr:primaryType.

 

There is no property to give the published status?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

560 likes

Total Posts

677 posts

Correct Reply

194 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

560 likes

Total Posts

677 posts

Correct Reply

194 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile
asutosh_jena
Level 10

22-04-2021

Hi @TB3dock 

 

You are running this query on your author instance where you have both published and unpublished pages. But your query is going to run on publish at the end of the day and no unpublished pages will be available on publish instance. So user will not be able to see any unpublished pages as part of the search result.

 

You can still use the below 2 property to query but it becomes redundant on publish instance.

2_property=@jcr:content/cq:lastReplicationAction
2_property.value=Activate

 

Thanks!

Answers (1)

Answers (1)

Avatar

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

190 likes

Total Posts

239 posts

Correct Reply

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

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

190 likes

Total Posts

239 posts

Correct Reply

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

22-04-2021

Hi,

 

When a page is activated we will have below properties and can be added in query to retrieve only published pages

 

2_property=@jcr:content/cq:lastReplicationAction
2_property.value=Activate

 

For unpublished pages the cq:lastReplicationAction property wont be present in jcr:content node and for deactivated pages it will have value as Deactivate.

 

Hope this helps !