The submodule containing the interface CategorizationSupport (moved from STK with the release of Magnolia 5.4).
If you are using a preconfigured Magnolia webapp or bundle - the modules are already included. The same is true if you are using a custom webapp based on
Maven is the easiest way to install the module. Add the following to your bundle:
<dependency> <groupId>info.magnolia.categorization</groupId> <artifactId>magnolia-categorization</artifactId> <version>2.6</version> </dependency>
magnolia-categorization depends on
magnolia-categorization-support. It is sufficient to add the former to the pom file of your webapp.
Pre-built jars are also available for download. See Installing a module for help.
What is a category?
A category is a non-hierarchical keyword assigned to a piece of content. Categories help you describe and find content. Compared to building hierarchy, categorization is a "bottom-up" approach. You can classify your content in unlimited number of ways and there is no "wrong" choice. Instead of belonging to only one category, an item may belong to several.
Categorization is typically a prerequisite to faceted search. You first need a faceted classification system. Then you can combine facets to filter content quickly.
Example: Tour types in the Magnolia Travel Demo are categories:
cultural and so on.
Categories assigned to a content item are typically displayed as links on the website.
Use the Categorization app to create categories.
- Category name (required): Internal name used to access the category programmatically, for example with catfn functions.
- Display name: Friendly name displayed to users when the category is rendered as a link on the website, for example.
- Importance: Gives the category more weight. Use importance to promote certain categories and influence their presentation.
- Related categories: Links to other categories. Helps visitors discover other related content.
Create your own app
Create your own app to manage a subset of categories. Authors appreciate it when they can focus on one thing at a time such as categories for a particular purpose. Managing a smaller subset reduces cognitive load and helps authors work more efficiently. The Tour Categories app in the Magnolia Travel Demo is an example of this strategy. The app only shows categories that apply to tours.
To categorize content, edit the content item's properties and choose applicable categories.
Example: A tour of Kyoto is categorized as
offPath (off the beaten path).
The easiest way to make categorization available to editors is to use the ready-made
categories field from the Categorization module. This generic multivalue field allows editors to apply any number of categories to the content item.
- JCR: If you configure your dialog or editor using JCR nodes, extend the
- YAML: If you configure your dialog or editor using a YAML file, paste the
categoriesfield into your form definition.
The Tours app extends the
categories field. The additional
property narrows the choice to categories in the
Here is an example how to add the
categories field to a YAML dialog definition.
Getting content by category
catfn functions to access categorized content in your templates. This set of templating functions helps you find content in a particular category. A typical use case is to offer the visitor similarly tagged pages, helping them discover additional interesting content.
Example 1: List all pages tagged with
travel. See Category overview for a ready-made template that does the same.
Example 2: List the categories of the current page.
More examples: catfn
The Categorization module provides templates for common use cases. Check them out before you write your own.
Category overview is a page template that offers visitors similar content based on the category they have clicked. The page renders links to other pages that belong to the same category.
The category overview template is available as a page and as a component:
categorization:pages/categoryOverviewis the page template. The page autogenerates the component for your convenience. You need to add this page on your site if you want to use the category cloud component. Links in the category cloud take visitors to the category overview page. The Category Overview page definition includes two properties
subtype=categoryOverviewwhich make the page a link target.
categorization:components/categoryOverviewis the component template. You can add the component to any page, it doesn't have to be on the Category Overview page, but you need to add the
subtype=categoryOverviewproperties to the page definition if you want links the cloud component to work.
Visitors typically request the category overview page by passing a category name as a selector in the URL:
category-overview.htmlis the page name.
~travel~is a category name as a selector.
You can style the page as you like. Make a simple textual index or visually attractive teasers. Here's an example from the Travel Demo that teases tours in the
A tag cloud is a weighted list of keywords. The importance of each tag is shown with font size. Bigger font means the tag is more prominent or more content is tagged with the tag. Visitors can quickly see what is hot on the site.
Magnolia's category cloud is different from a typical tag cloud. Instead of using the number of tagged items as weighting criterion, editors assign an importance level to each category. The higher the importance, the bigger the font. This mechanism allows editors emphasize prime content. For example, if you run an ecotourism campaign on a travel site, set the importance level of the ecotourism category to 5. This makes the category big in the cloud and drives more clicks to campaign content.
Links in the cloud point to the Category overview page, which means you must have a category overview page on your site.
The category cloud template script renders an unordered (bulleted) list of links by default:
Add your own style sheet to make the list look like a cloud, such as: