Skip to content

Latest commit

 

History

History
59 lines (44 loc) · 1.74 KB

02-config.md

File metadata and controls

59 lines (44 loc) · 1.74 KB

Configuration – Tags Bundle

  1. Installation
  2. Configuration
  3. Backend interface
  4. Custom managers

Add the service

First of all you need to add your own service. By default you can use the default manager which stores the tags in the tl_cfg_tag table and uses Contao models behind the scenes.

Note that for any manager you register you have to explicitly specify the service tags!

services:
    app.article_tags_manager:
        class: Codefog\TagsBundle\Manager\DefaultManager
        arguments:
            - "tl_app_article"
            - "tags"
        tags:
            - { name: codefog_tags.manager, alias: app.article }

Adjust the DCA files

Once the service is ready to use you can create a new field in the DCA and register it there. Make sure that you register it with the alias of the service and not the service name!

// dca/tl_app_article.php
'tags' => [
    'label'     => &$GLOBALS['TL_LANG']['tl_app_article']['tags'],
    'exclude'   => true,
    'inputType' => 'cfgTags',
    'eval'      => [
        'tagsManager' => 'app.article', // Manager, required
        'tagsCreate'  => false, // Allow to create tags, optional (true by default)
        'tl_class'    => 'clr'
    ],
],

Do not forget to set the source label for the tags backend module:

// languages/en/tl_cfg_tags.php
$GLOBALS['TL_LANG']['tl_cfg_tag']['sourceRef']['app.article'] = 'Article';

Update the database (optional)

Each manager takes care of loading and saving the data from the widget itself. The default manager internally uses Haste-ManyToMany field relation to store the data, so you need to update the datbaase before using it.