Plugging tokens into a block's title only shows the input text instead of what the token's supposed to output.

Is there a way to enable/use tokens in block titles, or maybe an alternative method of getting the results I want?

I've tried using Token Filter module, but it doesn't change the functionality.

I am trying to insert the [user:profile-realname] token into a block title (specifically the User Menu block title). The token is in my list of tokens available to use via HELP in the backend.

  • 1
    drupal version? where are you trying to set the title, inside a module or from the block admin page? what tokens are you trying to access?
    – Jimajamma
    Commented Dec 21, 2011 at 16:05
  • added version to title Commented Dec 21, 2011 at 17:57
  • Created an edit Commented Dec 22, 2011 at 20:13
  • a detail blog: goo.gl/77zEds Commented Jul 14, 2015 at 11:38

4 Answers 4


AFAIK, this cannot be achieved using the block title field, however using the Token Filter module, you can just drop the token in the body area of the block and wrap it in an H2 tag and it will appear as if it was the block title. (Just set the block title to <none>)

  • 1
    Does this also apply to the Node Title field? I want to add tokens to the Node title of the basic page content type, trying the same mechanism as Mechaflash. Will I also have to use Token Filter, or can I put Tokens directly into the Node title field (using the web interface, no php coding)? Commented Feb 15, 2012 at 16:16
  • no, it doesn't. If you wish to put it in the title field, you will need to follow Lance's answer to the question.
    – user842
    Commented Feb 15, 2012 at 19:36

Try the token_replace() function in the block preprocessor. Example:

$node = menu_get_object();  // Get the current node
if ($node) {
  $vars['elements']['#block']->subject = token_replace($vars['elements']['#block']->subject, array('node' => $node));

Maybe you have to load the user too to have the user tokens available.

  • I'm probably not going to try this as nicoz answer is the easiest way to do this. I would rather not mess with tpl files if I don't have to. Commented Jan 24, 2012 at 16:26

Once Support token replacement for block titles is implemented, you'll be able to use the [current-user:profile-realname] token.

  • 1
    So how do i reliable determine what tokens are going to validate? Or were you saying in that thread that there isn't a way to validate non-core tokens?
    – chrisjlee
    Commented Sep 28, 2012 at 14:57

Set Title to empty, and just add a Global Text Area in Views Header! Add here h tags or whatever html you want. Much easier and no coding required...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.