Organising content with tags and collections (v2)
9 April 2022 90 views | Documentation v2
Tags and collections are tools for grouping related content. They can be used to filter the contents of your home page or to create sections within your website.
The tagging system
Tags are essentially subject labels that you can apply to content. You can apply as many tags to a content item as you want. Visitors can use the tag select box on the home page to filter your site by subject. When an individual content item is viewed it will display a list of its tags, which will direct visitors to related content.
Tags are created with the standard content entry form by selecting 'Tag' as the content type. Once a tag is created it will appear as an option in the ‘tag’ field of the form when entering new content, and as an option in the tag select box on your home page (once you have tagged something with it, as empty tags are not displayed).
Tags are important content items in their own right and represent a logical ‘section’ or navigation handle in your site (see below), so it is good practice to provide them with a nice teaser, description and image. They are returned in search results and can be viewed as a single object, in which case they will display a list of related content teasers below the tag description.
Excluding tags from the tag select box
The tag select box is a primary navigation element for your site. If you add a lot of tags you may find that the drop down list becomes cluttered and unwieldy. You may not want to have every tag included in it. To exclude a tag from the public (front end) select box simply mark as 'offline'. It will still be present and fully available on your site, but it will no longer appear in the select box. "Offline" tags are still displayed when an individual content item is viewed, and on the administrative back end tag select box.
Collections represent a group (category) of related content, for example an album of music would make a good collection object and its members would be individual soundtracks (ie. audio content items that you uploaded separately). However, collections can contain a mixture of items - you can have text articles, audio and video files, images etc. all within a single collection.
Collections are created through the standard content entry form by selecting ‘collection’ as the content type. Once created a collection becomes available as an option in the ‘Parent’ section of the form. Other content items can be assigned to the collection by choosing it as their parent.
When the full description of a collection is viewed its member content items are displayed below it as a list of teasers. A member item that is viewed will also display a teaser at the bottom containing a link back to its parent collection. So collections and their elements are reciprocally linked, aiding navigation and discovery.
Collections can be nested, ie. one collection can be a member of another. In this way collections can function something like categories and sub-categories, although they are independent content items in their own right.
Creating custom tag select boxes
One useful application of collections is to use them to group related tags. Simply create a collection object and then edit each relevant tag, assigning that collection as their parent. For example, if you wanted a list of tags for different countries, you could create a 'Countries' collection and assign all your country tags to it.
Tag collections can be used to create customised select boxes, displaying only tags from a particular collection. If you would like to replace the default ‘global’ tag select box, you can do that by building it with a different method to gather the options, collectionTagOptions(int $id), which is found in the TagRead trait, or prepare a list manually. Basically you can prepare a tag list using any means you prefer and pass it in.
Copyright, all rights reserved.