Adding tokens to Views block title in Drupal 7

Summary: I wanted to use a token in the title on blocks generated by Views.
Solution: Adding a hidden field to the view to access the token, hiding the block title and then adding the title via a global text field.

I wanted to add a token (username of the userpage being viewed to be precise) to a block heading for a block rendered via Views. I found a suggested workaround for tokens in block titles where you hide the block title with <none> and add it in <h2> tags to the block body.

The block is generated via Views, so I instead, having hid the title, used an unfiltered global text field in the view header. To access the tokens I needed, I need to then add the appropriate field to my view, then check the “Use replacement tokens from the first row” box. That gave me what I needed to create a dynamic and contextually aware block title.

student teacher breakdown_staff view  Content    The English Farm

No comments yet.

Leave a Reply