- Training Topics
- Campus Connections
- OSU IT Policies
The Token module is somewhat difficult for newer architects to understand because it doesn't do much of anything "on the surface". Instead, it integrates with other modules in OSU Drupal such as CCK, Views, and Pathauto. It's one of those utility modules that kind of sits in the background and does an amazing amount of work without the end user ever knowing it.
This is really the way we like it in Drupal - seamless automation where possible.
If you get Token use under your belt you'll be doing yourself a huge service.
So what, exactly, is a Token?
Simply put, it's a data placeholder.
As an example, say you have a custom recipe node type that has a special recipe imagefield in it.
You want to be able to configure that recipe imagefield so that when your authors upload pictures through it, the pictures are automatically stored in a file folder that is organized in a path that collects ALL of your recipe pictures togther and you might even want that file folder name to match the name of the node that your image is being embedded into.
that reads like this: my-recipe-site/sites/default/files/recipes/lasagne
Moreover, you do not want to have to go in and create a new directory for each node that your authors create.
How would you automate this? Can you?
Absoultely you can! You would use token values in your imagefield configuration. So let's take a look at this...
A token is often called a Field Replacement Pattern in Drupal. When you are using a module, such as CCK, that works with the Token module, it will present a large list of available tokens that you can use. When you open the list, it can be a little bit daunting, but don't be taken aback by it...those are just all of the different things you can use if you so choose.
Tokens possess a special format that includes a set of square brackets around it, like this [title]. When you insert the token into your string of characters, you include the brackets along with the text.