Realname: Altering the name on the Navigation menu

Last modified: March 13, 2009 - 14:44

The User module produces the Navigation menu block. Strangely, it fails to use its own theme code to show the name (see #192056: User's raw login name should not be output directly). Since I cannot, in good conscience, encourage a core hack (simple as it may be), I had to find another way to fix this.

Aha, you are allowed to change your theme code! So just change this piece of PHP code within the block.tpl.php file of your default theme from

<?php print $block->subject ?>

to

<?php global $user; print ($block->module == 'user' && $block->subject == $user->name) ? theme('username', $user) : $block->subject ?>

This also adds the new "feature" that the block's title links to the user profile (account) page, effectively becoming an alternate way to reach your "My account" page.

 
 

Drupal is a registered trademark of Dries Buytaert.