Adds the possibility to assign tags to individual elements (news articles only at the moment).

Installs: 290

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 1

Open Issues: 1


0.1.14 2023-09-19 14:10 UTC

This package is auto-updated.

Last update: 2023-09-19 14:11:52 UTC



Adds the possibility to assign tags to individual elements.

System requirements

Installation & Configuration

  • Install via Contao Manager or Composer (composer require numero2/contao-tags)

  • Add the following code snippet into your news_(full|latest|short|simple).html5 template

    <?php if( $this->tags ): ?>
      <div class="tags">
        <?php foreach( $this->tags as $tag ): ?>
          <?= $tag; ?>
        <?php endforeach; ?>
    <?php endif; ?>
  • Configure your Newslist or Newsreader front end modules and set a Redirect page for tags

  • Additionally add the new Tag Cloud module anywhere on your page

For Developers

Integrating a tags field in your own extension

If you want to use the tags for fields in your own Data Containers you can do so by defining the field as follows:

$GLOBALS['TL_DCA']['tl_my_extension']['fields']['my_tags'] = [
    'exclude'           => true
,   'inputType'         => 'select'
,   'foreignKey'        => 'tl_tags.tag'
,   'options_callback'  => ['numero2_tags.listener.data_container.tags', 'getTagOptions']
,   'save_callback'     => [['numero2_tags.listener.data_container.tags', 'saveTags']]
,   'eval'              => ['multiple'=>true, 'size'=>8, 'tl_class'=>'clr long tags', 'chosen'=>true]
,   'sql'               => "blob NULL"
,   'relation'          => ['type'=>'hasMany', 'load'=>'eager']

foreignKey, options_callbackand save_callbackare mandatory. In the eval section we add a class called tags - this is also needed for the JavaScript handling. There are some more options which can be defined in eval.


Option Description
groupTagsByField If set to true the user will only be able to select from a list of tags that have been already used on this specific field in the current table. If set to falseor not set at all, the user will be able to choose from all tags available.