Skip to main content

Themes and categories behavior

Project description

Introduction

This contains two dexterity behaviors, vocabularies and indexers for two ‘taxonomy-like’ fields:

  • classifiers_themes (e.g. Air, Air > Quality, Air > Pollution, Water)

  • classifiers_categories (e.g. Report, Project, Project > Management)

Use case

You want to show some information on your website and make it easy to find it. You have reports about air or about water. You also have projects about those themes or specifically about air quality. Some projects are about both air and water. Some reports are specifically for management and some are more technical.

You want to be able to search all projects that are about the theme air, whether this is about air in general or specifically about air quality. You also want to search on air quality in particular, without finding the air pollution report.

How do you put this in a Plone Site? A traditional way would be to make two new content types: Report and Project. You add a checkbox or radio button to both types so you can mark them as technical or for management. You use the tags field to add an air quality tag or other tags for the themes.

This can work, but it has a few downsides:

  • You need two new content types, even though apart from the checkbox there is no difference between this and a standard page or maybe a folder.

  • Not all tags are themes. Editors may use tags for anything. You may have an add-on or some custom code that already uses tags, for example to mark an item for showing up on the home page or in a collection. So the theme tags get lost in the other tags.

Alternatively, instead of adding two new content types, you can use tags to tag a standard page as a project or report and as technical or for management. This clutters up the tags even more.

To mark an item as a certain theme, you can also use a taxonomy, for example collective.taxonomy. This is more flexible than this package, but it may be overkill, trying to do too much.

Instead, collective.classifiers basically adds two fields, which get their data from two dictionaries in the Plone configuration registry.

Installation and usage

Just add collective.classifiers to the eggs of your zope instance in your buildout config, run buildout, and start the zope instance. Go to the Plone Add-ons control panel of your website. First activate Dexterity content types if you have not done so already. Then activate collective.classifiers.

Go to the Classifiers Settings control panel, which simply accesses the Plone configuration registry with a filter on collective.classifiers. You can edit the data there to create categories and themes that fit your situation. If editing does not work because you get validation errors, please see the Dependencies section.

Let’s say you add this data:

  • Category Report, with sub categories Management and Technical.

  • Category Product, with no sub categories except a white space character. This is a trick to allow a top level category without any sub categories, as the top level may be enough. The same trick can be done with themes.

  • Theme Air, with sub themes Quality and Pollution.

  • Theme Water, with sub themes Rain and Rivers.

Go to a type on the Dexterity types control panel, for example a Page. Activate the categories classifiers and/or the themes classifiers behavior.

You can now create or edit a Page and select multiple categories and themes. With the above data, you have these categories to choose from:

  • Report

  • Report > Management

  • Report > Technical

  • Product

You will have these themes:

  • Air

  • Air > Quality

  • Air > Pollution

  • Water

  • Water > Rain

  • Water > Rivers

Let’s say you pick as category Report > Management and you pick two themes: Air and Water > Rain.

The categories and themes are shown on the default view of the page, but what is more interesting is that you can search for them in a Collection. In the edit form of a Collection you can select Classifier Categories and Classifier Themes. If you select as category either Report or Report > Management, the page will be found. If you select as theme either Air, Water or Water > Rain, the page will be found.

Dependencies

This is tested on Plone 4.3.2 with one version updated to a newer release: plone.app.z3cform 0.7.5. This should be the default in a future Plone 4.3.3 release. If you use an older plone.app.z3cform release, editing the dictionaries through the web is not possible. You would need to update the dictionaries by importing a registry.xml with your wanted settings then. See collective/classifiers/profiles/testfixture/registry.xml for an example.

Should work with Plone 4.2 as well, with the same remark about not being able to edit the dictionaries through the web.

Sponsorship

Work on collective.classifiers has been made possible by The Flemish Environment Agency or VMM. See http://www.vmm.be . VMM operates as an agency of the Flemish government for a better environment in Flanders. Flanders is one of the three Belgian regions with its own government, parliament and administration. The other two are the Brussels-Capital Region and the Walloon Region.

Changelog

1.0.0b2 (2022-07-05)

  • Gave names to our behaviors: collective.classifiers.themes and collective.classifiers.categories. [maurits]

  • Tested on Plone 5.2 and 6.0 with all supported Python versions. This includes Plone 5.2 on Python 2.7. [maurits]

1.0.0a1 (2021-09-20)

  • Add patch/hack to provide context to the vocabularyfactory when it’s not available: mainly in datagridfield rows. [f.vandijk]

  • Plone 5 compatibility. [f.vandijk]

0.4.1 (2014-04-07)

  • Add descriptios to our classifier and theme fields and provide Dutch translations. [fredvd]

0.4 (2014-03-05)

  • Add upgrade step to fix the values currently in the catalog. [maurits]

  • Do not let themes and categories end up in the catalog index when the behavior is not activated for a portal_type. [maurits]

0.3 (2014-02-24)

  • Handle case where values is None. [maurits]

0.2 (2014-02-24)

  • Make values not required. Until now you could fake an empty values list by typing a space as value. In some circumstances, next time you edited the configuration, you would need to do this again because the space was stripped. [maurits]

0.1 (2013-11-09)

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

collective.classifiers-1.0.0b2.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

collective.classifiers-1.0.0b2-py2.py3-none-any.whl (23.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file collective.classifiers-1.0.0b2.tar.gz.

File metadata

File hashes

Hashes for collective.classifiers-1.0.0b2.tar.gz
Algorithm Hash digest
SHA256 531d0ebfd9b23023ef8b07567cc38796159c28bccc95654c09b86e9f99115788
MD5 4b9561e0d0165ba8d47c1e9f9e2f6a53
BLAKE2b-256 3aeefe3ee6cf8ece454a9cd791462f697c3fe676eb75baed7759490da9bc10c0

See more details on using hashes here.

File details

Details for the file collective.classifiers-1.0.0b2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for collective.classifiers-1.0.0b2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e5dffa44b1b6b6afc5f7bcc630e5d825a7ace77452151de2070b896fabea3c35
MD5 822eacde95c6f0320b217b79d33d9b75
BLAKE2b-256 1ea6a15d6d52d5c7d385bbac4298e26fca823608e34e0997359eafaf5cdc962e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page