Skip to main content

Create, edit and use hierarchical taxonomies in Plone!

Project description

This add-on provides support for hierarchical taxonomies in multiple languages, letting users easily associate existing content with terms from one or more taxonomies.

Taxonomy is the “discipline of defining groups […] on the basis of shared characteristics and giving names to those groups. Each group is given a rank and groups of a given rank can be aggregated to form a super group of higher rank and thus create a hierarchical classification”.

Here’s an example of the “taxonomic kingdoms of life”:

Living Organisms
Living Organisms -> Eukaryotic
Living Organisms -> Eukaryotic -> Simple multicells or unicells
Living Organisms -> Eukaryotic -> Multicellular
Living Organisms -> Eukaryotic -> Multicellular -> Autotrophic
Living Organisms -> Eukaryotic -> Multicellular -> ...
Living Organisms -> Prokaryotic
Living Organisms -> Prokaryotic -> Archaebacteria
Living Organisms -> Prokaryotic -> Eubacteria
Living Organisms -> Prokaryotic -> Eubacteria -> ...

Taxonomies can be quite large, sometimes in the tens of thousands (10,000+). And in sites with multiple languages, each title – or caption – must appear in translation.

Note that the selection of a term in the hierarchy implies the selection of all its parents. In the example above this means that if “Eubacteria” is selected, then also “Prokaryotic” and “Living Organisms” will be.

Overview

The implementation tries to meet the following requirements:

  1. Support many (10,000+) terms.

  2. Terms can be organized in a hierarchical classification.

  3. Easily import and export in a common format (VDEX).

  4. Taxonomies will provide vocabularies that are translateable.

  5. Use behaviors to provide a choice field for each taxonomy.

  6. Manage taxonomies and assign to content types “through-the-web”.

In the description below, we touch on each of these requirements.

Data structure

In order to limit both the memory and computation requirements, the term data is contained in exactly one persistent index per language, a mapping from the materialized term path to its term identifier.

The term:

Living Organisms -> Eukaryotic -> Simple multicells or unicells

will be indexed under this path:

"Living Organisms/Eukaryotic/Simple multicells or unicells"

The index allows us to provide an iterator over the sorted vocabulary terms, virtually without cost (as well as containment queries).

At the same time, while the hierarchy is encoded, we can quickly look up terms in a subtree.

Note: As collective.taxonomy uses slash as separator, you have to monkey patch the PATH_SEPARATOR constant if you want to use ‘/’ in your terms.

Data exchange

While collective.taxonomy (this package) does make it possible to create, manage and edit taxonomies from a browser-based interface, the primary focus is to support the exchange of terms in the VDEX format:

The IMS Vocabulary Definition Exchange (VDEX) specification defines a grammar for the exchange of value lists of various classes: collections often denoted “vocabulary”.

This exchange is integrated with GenericSetup which manages imports and exports using setup profiles. It is also possible to use the controlpanel for importing and exporting VDEX files.

The package comes with integration for the Dexterity content type framework: for each taxonomy, a behavior is available that adds a choice field which pulls its vocabulary from the taxonomy. The behavior is configurable in terms of field name, title and whether it allows the selection of one or more multiple terms. You should first install dexterity and then collective.taxonomy, otherwise the behaviors for the existing taxonomies will be missing.

How does it work?

The main objective during this project has been to get a high rate of through-the-Web administration. Therefore the use of the product will not require any Python programming nor configure.zcml directives.

In the controlpanel (/@@taxonomy-settings), the user can:

  1. Import taxonomies from VDEX files.

  2. Export taxonomies existing to VDEX files.

  3. Delete taxonomies

  4. Add and delete behaviours for taxonomies

When a new behavior is created for a taxonomy, it can easily be added to the desired content types using the content type control panel, provided by Dexterity. After this is done, the taxonomy is available on add and edit forms, and it is also available for collections, if plone.app.collection is used on the site. An index is also created, so the taxonomies can easily be used for catalog queries.

See a short guide on how to use the product here.

Development

React/Redux app to edit taxonomies

The view @@taxonomy-edit-data that allow users to edit the taxonomy data is a React/Redux app (the source code is in the javascripts directory.

Here’s a preview of this view:

Edit taxonomy data preview

The languages allowed for the taxonomies are the languages defined in portal_languages.

Development

Run the app, run npm start in the javascripts directory. To make Plone use the development code, you need the NODE_ENV environment variable to be set to development:

NODE_ENV=development bin/instance fg

i18n

The app uses react-intl to handle i18n. To translate the app, add a new language in the translations directory. For example, create a es file in the translations directory that contains:

const es = {
    submitLabel: 'Enviar',
}

export default es

Then, edit translations/index.js to add the language to the translations object:

import es from './es'

const translations = {
    es,
    fr
}

You’ll have to rebuild the js bundle: npm run build

That’s it!

Requirements

  • Plone 4.3

  • or an older version using a recent version of plone.dexterity/plone.app.dexterity

Frequently Asked Questions

How can I import an existing ATVocabularyManager vocabulary?

Use the script provided in this gist. Just remember to edit the vocabIdentifier and vocabName.

To-Do

Travis CI badge Coveralls badge
  • Better documentation.

Contributors

Author

Contributors

Existing work

In 2010, Rok Garbas <rok@garbas.si> reimplemented and extended prior work by Seantis and released collective.vdexvocabulary. This package allows you to configure and populate vocabulary components from a VDEX-specification. The package supports flat vocabularies only, and support for multiple languages takes a different approach (vocabularies are returned in an already translated form). Note that vocabularies are loaded in a read-only mode, although it’s been proposed that vocabularies might be edited through-the-web.

In 2005, Jens Klein <jens.klein@bluedynamics.com> released ATVocabularyManager. This package makes it possible to create taxonomies using Plone’s content management interface with terms existing as regular site content. It’s integrated with the Archetypes content type framework (now deprecated).

Changes

1.4.2 (2016-11-08)

  • Fix save action in edit-taxonomy-data. This was a regression in 1.4.0, the get parameter should be taxonomy, not form.widgets.taxonomy. [cedricmessiant]

1.4.1 (2016-11-03)

  • Remove Save and Cancel buttons in controlpanel introduced 1.4.0. [vincentfretin]

  • Add missing upgrade step to create records in registry. [vincentfretin]

1.4.0 (2016-11-03)

  • Getting language by acquisition, indeed some Dexterity content has no language or empty language. [bsuttor]

  • Fix empty context.REQUEST.get(‘form.widgets.taxonomy’). It add it into POST form. [bsuttor]

  • Plone 5 compatibility [tomgross]

  • Use context language to find index. [bsuttor]

1.3.0 (2016-07-07)

  • Fix index when taxonomy is added as field. [bsuttor]

  • Now uses a React/Redux app to edit taxonomy data. It is now possible to edit the data in multiple languages and to compare between languages. [cedricmessiant]

  • Fix index when taxonomy is added as field. [bsuttor]

  • Now uses a React/Redux app to edit taxonomy data. It is now possible to edit the data in multiple languages and to compare between languages. [cedricmessiant]

  • Add PATH_SEPARATOR constant to be able to use ‘/’ character in terms. [cedricmessiant]

  • Add ++taxonomy++[shortname] -traverser to be usable with PloneFormGen dynamic field vocabulary overrides [datakurre]

  • prevent taxonomy reset on reinstall if you’ve defined a vdex xml file in your profile [petschki]

  • Plone 5 compatibility [tomgross]

1.2.3 (2014-02-07)

  • ConfigParser supports allow_no_value on Python 2.6, so we cannot allow empty values, only on 2.7 or newer. [bosim]

1.2.2 (2014-01-03)

Bugfix release

  • Fixed problem with registration of search citeria in collections, the previous registration broke export feature of plone.app.registry. Upgrade step has been added so please upgrade. [bosim]

1.2.1 (2013-11-12)

Bugfix release, please upgrade

  • Using Schema from plone.supermodel. Fixes issue #6 [bosim]

  • Rewrote behavior creation routine. Fixes issue #5 [bosim]

1.2 (2013-11-12)

  • Add collective.js.jqueryui as dependency. Install it automatically. [maurits]

  • i18n fixes, messages extraction script, french translation. [thomasdesvenain]

  • Fixed error in vdex import. [thomasdesvenain]

  • Avoid failure at export when no default language was selected. [thomasdesvenain]

  • Remove dependency form plone.directives [thomasdesvenain]

  • Added elementtree in dependencies [thomasdesvenain]

1.1 (2013-07-16)

  • Taxonomies can now be added without uploading a VDEX file. [bosim]

  • Taxonomies can be exported/imported via GenericSetup again. [bosim]

  • Single select fields are now possible again. [bosim]

1.0 (2013-05-07)

  • Initial release [bosim]

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.taxonomy-1.4.2.tar.gz (335.1 kB view hashes)

Uploaded Source

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