Tags can be used to mark content and/or pages for easy retrieval in other contexts, or to treat them differently. There are several types of tags, which are not used in the same way.

  1. Label types
    1. Applications
    2. Graphic charter
    3. Customized
  2. How do you define a label?
  3. How do I use a label?
    1. Page labels
    2. Content tags

Label types

Applications

These labels are supplied by the extension point org.ametys.web.tags.TagProviderExtensionPoint in the plugin.xml. They are generally used by services. For example, plugin Glossary provides a page tag to determine which page contains the glossary, so that each definition can be redirected to it.

Graphic charter

Graphic charter labels are mainly used to influence the charter by labeling a page or content. For example:

  • to make a page invisible in the menus or site map,
  • to build menus and submenus,
  • to select the pages to appear in the footer,
  • to assign a color variation to a page,
  • to highlight specific content,
  • not to display a content title,
  • etc ...

They are defined in a XML file called tags.xml is located in the cms/skins/[skinName]/conf/ folder.

Customized

Custom tags are defined by the contributor. In this way, they can classify content or pages according to their choice, and create content or page feeds based on this data. These labels are created using the Labels tool.

How do you define a label?

A label has several components:

  • Identifier

Name: id
Type:
attribute
Possible values: Uppercase characters with no spaces.
Description: The identifier uniquely identifies the label. Two categories or labels cannot have the same identifier.

  • Wording

Name: label
Type:
node
Possible values: keys i18n with or without catalog or directly a text
Note: The label node can contain the attribute i18n="true/false" to indicate whether it is a label i18n or a text.
Description: The label will be displayed in the list of available labels.

  • Description

Name: description
Type: node
Possible values: keys i18n with or without catalog or directly a text
Note: The label node can contain the attribute i18n="true/false" to indicate whether it is a label i18n or a text.
Description:
The description corresponds to the label's tooltip in the list of available labels.

  • Range

Name: target
Type:
attribute
Possible values:
page, content
Description:
A label can be applied to a content or a page, in order to define its scope, the correct value must be assigned to the target attribute.

  • Visibility

Name: private
Type:
attribute
Possible values:
true, false
Default value:
false
Description:
There are several rights, including the right to assign private labels. A contributor who does not have this right will not be able to assign a label of this type. However, he/she can view it, in particular to create reports.

Example:

<tag id="FOOTER_LINKS" target="PAGE" private="true">
    <label i18n="true">SKIN_BO_TAGS_CAT_SPECIALPAGES_TAG_FOOTERLINK_LABEL</label>
    <description i18n="true">SKIN_BO_TAGS_CAT_SPECIALPAGES_TAG_FOOTERLINK_DESCRIPTION</description>
</tag>

Labels can be hierarchical: a label can contain one or more daughter labels.

For more details on defining a graphic charter label, see tags.xml.

How do I use a label?

Page labels

Page labels can be used in filters, defined in cms/skins/[skinName]/templates/[templateName]/filters/default.xml. In this case, the returned data is already sorted according to the selected labels.

It is also possible to read page tags in the sitemap, for example, to create the menu. In this case, the SECTION label (label identifier) is searched for in the sitemap pages. These represent the menus. In the sitemap, all tags are prefixed by PLUGINS_TAGS_.

For example:

<ul>
    <xsl:for-each select="/cms/sitemap//page[@PLUGIN_TAGS_SECTION]">
        <li><a href="{$site-uri-prefix}/{$lang}/{@sitemap:path}.html"><xsl:value-of select="@sitemap:title"/></a></li>
    </xsl:for-each>
</ul>

It's also possible to retrieve a tag from the current page without using the sitemap, via the page's tags. For example, you can hide the sub-menu of the current page as follows:

<xsl:if test="not(/cms/page/tags/NO_MENU)">
    <!-- Création du sous-menu -->
</xsl:if>

Content tags

Content tags are retrieved each time content is generated, regardless of the view selected. Tags are found in the content's tags tag. To retrieve tagged content, proceed as follows:

<xsl:if test="not(tags/WITHOUT_TITLE)">
    <h1><xsl:value-of select="title"/></h1>
</xsl:if>
Back to top