0

I wish to call a token directly from the WYSIWYG text editor of a node of a certain content type.

For example, I wish to call the token [current-page:title] (node H1 tag) from the edit page.

So, for example for a node named "Tulip (Tulipus)":

Input

The term [current-page:title] [plural: Tulipa] is used to describe a flower of the family Liliaceae.

Output

The term Tulip (Tulipus) [plural: Tulipa] is used to describe a flower of the family Liliaceae.

How can this be done?

1 Answer 1

2

You'll want the Token Filter module.

As the module's page says, you need to make sure you have the right context for the tokens you want to use; if the context isn't available, token replacement will fail silently.

Also note that it's not yet ready for CKEditor 5.

5
  • Hello Patrick and thank you. I have read in the module's page but it isn't clear to me what the word "context" means here, is it the node versus block issue detailed there? I plan to use it only for nodes.
    – meta
    Jul 2 at 15:28
  • Should using "token filter" as an input filter interfere with some HTML parsing?
    – meta
    Jul 2 at 15:38
  • May I add that the documentation page lacks clear data in these regards as well: drupal.org/docs/contributed-modules/token-filter
    – meta
    Jul 2 at 15:39
  • 1
    Tokens are usually linked to an entity, so for such tokens, the entity is the context. If you use a token when it would not be available, it will fail. Drupal usually gives you a widget to show the available tokens, but Token Filter d module does not have this; you will have to either use tokens that you know are safe or proceed carefully by trial and error. Jul 2 at 17:03
  • Oh, as I figure now, the only token I am going to use is [current-page:title] within nodes.
    – meta
    Jul 2 at 18:04

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.