Skip to content

Taxonomy

Taxonomies (Tags) allow you to organize content to make it easy for your site users to browse and to deliver content appropriate for them. Taxonomies are classifications of logical relationships between content. In Ibexa DXP you can create many taxonomies, each with many tags. The platform mechanism enables creating any entities with a tree structure and assign them to a content item.

Default tag configuration is available in config/packages/ibexa_taxonomy.yaml The associated content type is tag.

1
2
3
4
5
6
7
8
9
ibexa_taxonomy:
    taxonomies:
        tags:
            parent_location_remote_id: taxonomy_tags_folder
            content_type: tag
            field_mappings:
                identifier: identifier
                parent: parent
                name: name

Configuration keys

  • ibexa_taxonomies - section responsible for taxonomy structure where you can configure other taxonomies
  • ibexa_taxonomies.tags.parent_location_remote_id - Remote ID for Location where new content items representing tags are created
  • ibexa_taxonomies.tags.content_type - Content type identifier which stands for the tags
  • ibexa_taxonomies.tags.field_mappings - Field Types map of a content type which taxonomy receives information about the tag from.

Three fields are available: identifier, parent and name. The identifiers correspond to Field names defined in the content type. The name Field is used to automatically generate an identifier.

Customize taxonomy structure

You can create other taxonomies than the one predefined in the system, for example a Content category.

To do it, first, create a new container to store the new taxonomy's items, for example a folder named "Content categories".

Next, under the ibexa_taxonomy.taxonomies key add the following configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
ibexa_taxonomy:
    taxonomies:
        # existing keys
        content_categories:
            parent_location_remote_id: <content_categories_remote_id>
            content_type: content_category
            field_mappings:
                identifier: category_identifier
                parent: parent_category
                name: name_field
            assigned_content_tab: false

Replace <content_categories_remote_id> with the new container's Location remote ID.

Translate the configuration identifier in the ibexa_taxonomy domain by, for example, creating a translations/ibexa_taxonomy.en.yaml file containing the following:

1
taxonomy.content_categories: 'Content categories'

Then, create a content type with content_category identifier and include the following Field definitions:

  • name of ezstring type and required. Use this Field, as <name>, for content name pattern.
  • category_identifier of ezstring type and required.
  • parent_category of ibexa_taxonomy_entry type and not required. In its Taxonomy drop-down menu, select Content categories (or taxonomy.content_categories if no translation has been provided).

Finish taxonomy setup by creating a new Content category named Root with identifier content_categories_root under the previously created container folder named Content categories.

To use this new taxonomy, add an ibexa_taxonomy_entry_assignement Field to a content type and select Content categories (or taxonomy.content_categories) in its Taxonomy drop-down setting.

Hide Content tab

The Content tab in taxonomy objects, for example, tags and categories, lists all Content assigned to the current taxonomy. You can hide the Content tab in the Categories view.

In configuration add assigned_content_tab with the flag false (for other taxonomies this flag is by default set to true):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
ibexa_taxonomy:
    taxonomies:
        # existing keys
        content_categories:
            parent_location_remote_id: <content_categories_remote_id>
            content_type: content_category
            field_mappings:
                identifier: category_identifier
                parent: parent_category
                name: name_field
            assigned_content_tab: false

For more information about available functionalities of tags, see User Documentation.

Hide delete button on large subtree

The Delete button can be hidden when a taxonomy entry has many children. By default, the button is hidden when there are 100 children or more.

The delete_subtree_size_limit configuration is SiteAccess-aware, and can be set per SiteAccess, per SiteAccess group, or globally per default. For example:

1
2
3
4
5
6
ibexa:
    system:
        default: # or a SiteAccess, or a SiteAccess group
            taxonomy:
                admin_ui:
                    delete_subtree_size_limit: 20

Remove orphaned content items

In some rare case, especially in IIbexa DXP v4.2 and older, when deleting parent of huge subtrees, some Taxonomy entries are not properly deleted, leaving content items that point to a non-existing parent. The command ibexa:taxonomy:remove-orphaned-content deletes those orphaned content item. It works on a taxonomy passed as an argument, and has two options that act as a protective measure against deleting data by mistake:

  • --dry-run to list deletable content items, without performing the deletion.
  • --force to effectively delete the orphaned content items.

The following example first lists the orphaned content items for taxonomy tags, and then deletes them:

1
2
php bin/console ibexa:taxonomy:remove-orphaned-content tags --dry-run
php bin/console ibexa:taxonomy:remove-orphaned-content tags --force