Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a custom token in Drupal 7?

I need to create a custom token that can fetch a value from a mapping table based on nids. I need to know the hooks I should implement to create the custom token.

like image 606
Piyuesh Kumar Avatar asked Sep 24 '11 09:09

Piyuesh Kumar


1 Answers

You'll need to implement hook_token_info() and hook_tokens.

The best thing you can do is download the Examples module, there's a module called token_example with well commented example code for how to implement tokens properly.

like image 120
Clive Avatar answered Sep 19 '22 11:09

Clive