Categories

Core

The Categories module is deeply integrated into the core of Manifesto. Despite the name, this module provides a full taxonomy scheme with multiple hierarchies - distinguished as Category Groups - allowing you to classify your content in numerous ways. Many of the content types in Manifesto are explicitly designed to support categories and category groups, allowing you to assign one or more categories to your content, and easy filtering of content by category. Any class that is a descendant of the CategorizedObject class will automatically support the assignment of categories to its content types.

Category groups and modules have a many-to-many relationship, allowing you to assign/restrict modules to certain category groups, and allowing the same category group to be used by more than one module.

Category Groups

A category group defines the thematic coherence of its child categories. It could be "Food Groups" or "Countries" or "Decades" - anything you want to assign to your information to help classify it. Each category group may contain a virtually limitless list of sub-categories, sub-sub-categories, etc.

The category group contains a "description" field, but it is not displayed anywhere public-facing by default. It may be used for internal notes, or you might create your own category page that makes use of the description field.

When defining the category group, you may also specify whether or not that group supports multiple selections, or whether it permits only one category to be selected per content type. This setting affects the way categories are presented for editing on the back end.

A category group and its categories are not available to associate with content until you assign it to one or more specific modules (on each module's setup page). A module may take advantage of more than one category group, for example, an university course page may have both a "School" category and a "Department" category, so it would be associated with both "School categories" and "Department categories" groups.

Categories

Within every category group is one or more category. Categories may be organized into a hierarchic structure, with every category capable of having one or more sub-categories, ad infinitum. Each category has the following properties:

  • Category name
  • Shortname (used in URLs)
  • Description (not typically displayed)
  • Icon (an uploaded image used to represent the category)
  • Marked (a simple on/off flag that allows you to highlight certain categories)

You can use categories in a variety of ways, but it is commonly used to organize your data in ways that might be useful for your visitors to sort and filter by. Blog posts, for example, might be assigned a simple category from a list of topics you focus on. A record for a book or movie might have a category group for "Genre" and another category group for "Audience."

After assigning categories to your content, its easy to add a filtering menu at the top fo your module landing page to allow visitors to filter the output of your content based on category selections. The categories module contains a simple file that can be included on your page to provide the menu automatically.

Automatic category handling

Because filtering content by category is such a frequent operation, Manifesto's default routing parser automatically looks for a category filter passed in the URL, and assigns it as the default request category. Most controllers in Manifesto that are designed to handle categories will automatically adjust their queries when a request category is discovered.

The default category for a request is stored as $G->req_category, and can be accessed any time during the page request. If no specific category is requested, this variable is set to "all" (and queries throughout Manifesto are designed to check this value before performing any query modifications.

Note that Manifesto can only handle filtering by a single category in this manner. If your page flow allows or requires multiple category assignments, it will have to manage the database query adjustments within its own controller.