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

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

TB3dock
Level 8
Level 8

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?

1 Accepted Solution
Asutosh_Jena_
Correct answer by
Community Advisor
Community Advisor

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!

View solution in original post

0 Replies
Ravi_Pampana
Community Advisor
Community Advisor

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 !

Asutosh_Jena_
Correct answer by
Community Advisor
Community Advisor

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!

View solution in original post