Token Module: How I Learned To Use the Token API and Stop Re-Implementing Dynamic String Replacement
Greg Knaddison
Growing Venture Solutions
July 2008
DrupalCamp Colorado
What are Tokens?
Little bits of text that get replaced with other bits of text.
Have you used:
ecommerce like ec_mail Custom Breadcrumbs Organic Groups - og Automatic Nodetitles (aka auto_nodetitle) Pathauto Upload Path PressFlow Placement Ubercart Invite Tokenize Audio Workflow-ng CCK Taxonomy CCK Full Name CCK Taxonomy SSU (Super Select Ultra) Fieldset Menus Node Relativity Backup and Migrate User stats Simplefeed Page title Token Node Tokens (TNT) Temporary Invitation Activity Type-local nids FileField Actions Token Email for 5.x
Me too.
If you haven't...here's a quick demo.
Token for Developers:
// Consuming tokens
// [user-name] - The name of the currently logged in user.
$original = 'Hello [user-name]';
drupal_set_message(token_replace($original, $type = 'global', $object = NULL,
$leading = '[', $trailing = ']')
// Prints "Hello greggles"
Providing Your Own Tokens
hook_token_list()
hook_token_values()
Questions? Ideas For Improvement? Bugs?
Featured Team Member
Ben enjoys working on cutting edge technologies and finding practical ways to use those tools to make better sites for clients, faster.
Drupalcamp Colorado
We had fun at Drupalcamp Colorado!
We Wrote the Book On Drupal Security:
We were at Drupalcon San Francisco
See the videos now:







Comments
Post new comment