Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Veazer on
I'd like to be able to use the username in the block title for a Nice Menu block. I thought it might be as simple as using some kind of variable like:
Welcome, <$user->username>.
as the block title (or something to that effect) but evidently not. What is the best way to accomplish this?
Just the username itself as the block title would be fine as well. Ideally, i'd like to be able to control what title is used for anonymous users as well but it's not needed for this project as this nice menu is only shown to authenticated users.
Any tips are appreciated.
Comments
Reusing some of the code
Reusing some of the code here: http://drupal.org/node/58602
you can come up with something like this to use in your theme's block.tpl.php file:
Hope this sets you on the right track.
Perfect!
Thanks, that's exactly what I was looking for. I wish Drupal had a list of variables that could be used to do this through admin, but this will accomplish exactly what I needed. Much appreciated!
Thanks
thank you for this. I found this very helpful!
That Helped!
Can be used to create custom titles to blocks. Thanks! Edited the file block.tpl.php like this:
Original:
New: