Advanced Queries

Tags & Categories

Advanced queries are used in conjunction with the List component to build lists with specific parameters. To use one of the following queries, create a list component and select Advanced Search from the List drop-down.

Click the Advanced Search tab when it appears. Proceed to enter the text (examples at the bottom of this page) in the Querybuilder field. You can limit the items in your list by selecting from a particular path in your site tree, or using tags, or both.

Note: If you are using an advanced query to organize your pages by date via a Date Stamp component, be sure to leave the "Order by" drop-down menu blank.

The following are examples of how authors have made use of the Advanced Query function in AEM. For help with building custom queries to meet your needs, contact your Site Administrator.

1. Listing pages by path

NEWS
Displays pages that use the News or Blog template in your site path.

path=/content/sfu/[your site path]
type=cq:Page
1_property=jcr:content/sling:resourceType
1_property.value=clf/components/pages/news
daterange.property=jcr:content/main_content/datestamp/dateTime
orderby=@jcr:content/main_content/datestamp/dateTime
orderby.index=true
orderby.sort=desc

To display pages that fall within a particular timeframe (in this case, January 1, 2013 through January 1, 2014), add the "lowerBound" and "upperBound" options:

path=/content/sfu/[your site path]
type=cq:Page
1_property=jcr:content/sling:resourceType
1_property.value=clf/components/pages/news
daterange.property=jcr:content/main_content/datestamp/dateTime
daterange.lowerBound=2013-01-01
daterange.upperBound=2014-01-01
orderby=@jcr:content/main_content/datestamp/dateTime
orderby.index=true
orderby.sort=desc

Please note: 
If your site uses the CLF3 template, you will need to use the following template paths:

  • News or Blog template = clf/components/pages/clf3/news-clf3
  • Basic Home Page template = clf/components/pages/clf3/basic-home
  • Basic Page template = clf/components/pages/clf3/basic-sub

If your site uses the CLF4 template, you will need to use the following template paths:

  • News or Blog template = clf/components/pages/sfu-clf/v4/news-clf4
  • Basic Home Page template = clf/components/pages/sfu-clf/v4/basic-home-clf4
  • Basic Page template = clf/components/pages/sfu-clf/v4/basic-sub-clf4
  • Faculty Profile template = clf/components/pages/sfu-clf/v4/faculty-profile-clf4
  • Blank page or Pop up template = clf/components/pages/sfu-clf/v4/pop-up-clf4

UPCOMING EVENTS
Displays pages that are within your site's "Events" directory whose datestamp is greater than the current day. This query is can be used for displaying upcoming events on your home page or "Upcoming Events" page.

path=/content/sfu/[your site path]/[events parent]
type=cq:Page
relativedaterange.property=jcr:content/main_content/datestamp/dateTime
relativedaterange.lowerBound=-1d
orderby=@jcr:content/main_content/datestamp/dateTime
orderby.index=true
orderby.sort=asc

PAST EVENTS

To display events that have occurred in the past, use the query above and replace the relativedaterange line with:

relativedaterange.upperBound=-1d

2. Listing pages by tags

TAGGED PAGES
Displays pages that have been tagged with a particular tag in your namespace. In this case, the component will display all pages within the site that have been tagged "new".

path=/content/sfu/[your site path]/[event parent]
type=cq:Page
tagid.property=jcr:content/cq:tags
tagid=[your namespace]:new

MULTIPLE TAGS
This query will search and display pages that are tagged with "new" or "event". If you would like to display more tags, just add another property value line and increase the value by 1. (eg., property.3_value=[your namespace]:tag ID)

path=/content/sfu/[your site path]/[event parent]
type=cq:Page
property=jcr:content/cq:tags
property.1_value=[your namespace]:new
property.2_value=[your namespace]:event

LIMITING THE SCOPE OF YOUR TAGS
This query displays pages that have the same tag but are located in multiple areas of your site tree. This display can be used when you have used a tag throughout your site, but you don't want to list every page that contains that tag. In this case, the component will display pages in the "Generic" site that have been tagged with "deadlines" (tagid=generic:deadlines). It will also be limited to pages that are found under the "undergrads" or "graduates" page (group.1_path=/content/sfu/generic/undergrads and group.2_path=/content/sfu/generic/graduates). If a page was tagged with "deadlines" in another area of your site (e.g., /content/sfu/generic/keydates), that page would not be displayed.

group.p.or=true
group.1_path=/content/sfu/generic/undergrads
group.2_path=/content/sfu/generic/graduates
type=cq:Page
tagid.property=jcr:content/cq:tags
tagid=generic:deadlines