Labels

Categories

Component ID

2796663

Component name

Labels

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

This module provides developer-configurable labels that can be printed in any twig template. Admin users can edit the text that will be output wherever the label appears.

We often find ourselves providing custom blocks in order to allow site editors and administrators a simple way to edit text on sites. In some cases, this is a great solution. In other cases, it is overkill when a simple, editable text-label would suffice.

Usage

  • Site-builders and developers can see all configured Labels, create new Labels, or delete existing Labels by going to Configuration -> Labels (/admin/development/labels). For example, we could create a Label 'hello_world' named 'Headline Text'. The name is simply a descriptive name to help identify where on the site the Label appears.
  • Themers can then place those labels in any twig template. Our Hello World example would look like this: {{ label__hello_world }}
  • Site editors can then edit the replacement text of the Label by going to Structure -> Label Replacements (/admin/structure/labels). In our example, we set the Headline Text replacement value to be 'Hey there!'. Now anywhere on our site where we use the {{ label__hello_world }} label, it will now say 'Hey there!'.