Very Basic Custom Token

Last updated on
28 November 2024

Do you need to create the most basic of tokens? Do you need to be able to create a token that perhaps outputs just a single phrase or a even a single word? I needed to create a token for a piece of plain text information that would appear in multiple places all over my site, but was very likely to change from time to time. This is how I did it:

1. Go to Admin > Structure > Custom Token, click on Add Token
2. Enter a Token Name and Description
3. Choose "Custom Tokens" for the Token Type
4. In the PHP Replacement text area enter something like this:

$basictoken = 'My simple phrase or text';
return $basictoken;

5. Hit "Save Token"

Back on the Custom Token main page you will now see your custom token outputted in the "demo" column. You can use this new token as an input filter if you have the Token Filter module installed.

The token will be [custom:basictoken]

Help improve this page

Page status: Not set

You can: