Drupal - Using tokens in block titles

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>)


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.


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

Tags:

Tokens

Blocks