In the custom Drupal 8 block, there are no tokens.


How to set up a text format that replaces the tokens ?

I need to use in a custom block, the title of the current page, the creation date of the current page, ...

  • I expect it's the same way you use them with anything else; set up a text format that replaces tokens, then use that text format for the block body
    – Clive
    Apr 5 '18 at 9:14
  • @Clive Thank you. So how to set up a text format that replaces the tokens?
    – steeve61
    Apr 5 '18 at 9:21
  • drupal.org/project/token_filter is still in beta but I'd imagine works well enough to use
    – Clive
    Apr 5 '18 at 9:24

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

This doesn't mean that all tokens will work in every location. For example, if you use a [node:field_foo] token in the text of a block, the token system will not know which node you are referring to and will not replace the token. It is up to you when you are implementing this module to be aware of the context for token usage and use them appropriately


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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