Using Categories

Tags & Categories

What is a category?

A Category is a page in the WCM whose purpose is to organize a set of child pages. You can use categories to organize things like blog pages and news items, and display them based on their categories.

Categories are exclusive. Unlike tags, a page can only belong to one category at a time. However, a page can have a category, on top of any number of tags. This allows you to display a page by its category, tag, or by a combination of its tag and category.

Categories are beneficial for sites with large blogs or news pages, because they provide structure and organization to your pages in the WCM which tags cannot provide.

When to use categories

Categories are best used in parts of your site where you are adding lots of pages frequently. Typical use cases include blogs and news sites, or other situations where you need to create large amounts of pages and display them dynamically using lists.

Categories can also be useful for displaying blog archive posts about a particular subject without having to perform an advanced search.

Creating a category

In the WCM, navigate to the area of your site you want to create categories in.

  1. Click New...
  2. Create a page, using the Basic Content Template. Name the page the name of your category.
  3. Click OK.
  4. Create blog pages or news posts as child pages of your category.

Using categories in conjunction with tags

You can use categories in conjunction with tags to show further refine the posts or articles you show. As tags can be applied to pages regardless of category, you can use tags to show collections of posts independent of their category, or display a collection of posts within a particular category.

Advanced Query: Use a list to display tagged items in a particular category

You can use the following query to search for items tagged in a specific category.

group.p.or=true
group.1_path=/content/sfu/[your site path]/[your category name]
type=cq:Page
tagid=[your tag namespace]:[your tag name]
tagid.property=jcr:content/cq:tags

Advanced Query: Use a list to display tagged items from multiple categories

You can use the following query to search for items with a particular tag across all your categories. You can use this to create a "Featured" section of your blog or news site, for example, which pulls the most interesting stories (tagged "Feature", for example, but any tag will work) from the different categories in your site.

You can modify the following query to search more categories by adding group.3_path=, group.4_path=, etc. underneath the line group.2_path.

group.p.or=true
group.1_path=/content/[your site path]/[your category name]
group.2_path=/content/[your site path]/[your 2nd category name]
type=cq:Page
tagid=[your tag namespace]:[your tag name]
tagid.property=jcr:content/cq:tags

Advanced Query: Use a list to display items with multiple tags within a category

You can use the following query to search for items which match two different tags within a category. For example, if a category name was "News", and it was tagged "feature" and "people", the query would only display this item.

You can modify the following query to search for more tags by adding property.3_value=, property.4_value=, etc. underneath the line property.2_value=.

path=/content/sfu/[your site path]/[your category name]
type=cq:Page
property=jcr:content/cq:tags
property.1_value=[your tag namespace]:[your tag name]
property.2_value=[your tag namespace]:[your tag name]
orderby=@jcr:content/main_content/datestamp/dateTime
orderby.index=true
orderby.sort=desc