It took me a long time to figure out this simplest use of custom tokens after considerable searching, so I thought I'd drop my solution here. What I wanted to do was set up a global site variable that is easily editable in the Admin section by non-programmers. For example, say I wanted a list of keywords that any module, page, etc could access.

In the token admin I created a token called "token_custom_keywords"
The content of this token was:

print "good,nice,friendly";

Then anywhere else on the site I could access this as:

$myTokenString=token_replace("[token_custom_keywords]");

This works just as I wanted. Although if there's another module that does this in a more efficient way, I'd love to hear about it!

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

manuel.adan’s picture

Issue summary: View changes
Status: Active » Closed (outdated)
ressa’s picture

Version: 6.x-1.2 » 8.x-1.x-dev
Category: Feature request » Support request
Priority: Minor » Major
Status: Closed (outdated) » Active

I still think this is relevant ... I looked at the documentation https://www.drupal.org/docs/extending-drupal/contributed-modules/contrib..., but it says it is for the old version ("This page and its children are for old releases of the Custom Tokens module. See #2912199: Documentation").

Also, there isn't much in the README file ...

It would be great with a very simple example in the README or on a doc page, which shows what makes this module great, and how to set it up. Thanks!

anybody’s picture

Title: Really Simple Example/Documentation » Improve documentation
Category: Support request » Task
Priority: Major » Normal
Issue tags: +Novice

Yeah anyone feel free to create a proper and helpful README.md and updated description for the module page.

ivan zugec made their first commit to this issue’s fork.

jatin.buzz’s picture

Assigned: Unassigned » jatin.buzz

Working on it!

jatin.buzz’s picture

Assigned: jatin.buzz » Unassigned
Status: Active » Needs review

Please review readme.md improved