5

I added a new content type. How can I use tokens when editing a node of that content type?

For example, if I put "Hello [user:name]", the page shows the following:

enter image description here

As shown above, the "[user:name]" token in it is not replaced with the username.

0

2 Answers 2

5

You need a text filter to replace tokens in fields. You can configure them in admin/config/content/formats. In drupal 7 you can install the needed text filter with:

Token Filter

But this will not be ported to drupal 8 in the same way as in drupal 7:

Issue Token Filter in Drupal 8

As this is a very simple piece of code, there is an unofficial version for drupal 8:

token_filter-8.x

2
  • it works like to drupal7 or Drupal8 works differently?
    – link3d03
    Dec 3, 2015 at 8:28
  • With token_filter_8.x it works like in drupal 7. This is not an official drupal 8 port and I'm not sure, if this works 100 % for all kind of tokens. There may be some caching issues.
    – 4uk4
    Dec 3, 2015 at 8:43
4

This is something one typically does with the Token Filter module. Some details from its project page:

Token Filter is a very simple module to make token values available as an input filter.

The module now supports native tokens (e.g. [site:name]) and all global tokens by default. It even allows some contextual tokens like node or user to be replaced, but currently does not encourage users to use them in the filter help text.

This module currently has a beta version for D8.

1
  • This is the definitive answer for Drupal 7 Feb 12, 2016 at 3:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.