By johnhanley on
I collect the user's first and last name at registration time and store them (via hook_user) in a custom table (profile.module to general for my needs.)
I'm using the Blue Marine theme and would like to display the full name above the navigation instead of the user (account) name.
Where's the user name string above the navigation stored? (I haven't messed with themes at all--completely focused on functionality until now.)
Also, what's the best way to go about adding the full name to the user object so it's available globally?
Thanks.
Comments
The navigation block is set
The navigation block is set in user.module in the following line:
In your theme, I suppose, you could detect a theme_block() subject that's equal to $user->name and substitute your own data before outputting the block.
I'm lame
Yes, the navigation block (duh!)
I need to take a break 'cause that was too obvious.
It's all right there (just like the song, "Downtown") in the user.module.
nedjo, thanks for your help.
not so obvious after all
Ok, perhaps it's not as obvious as first thought.
I'm not clear what you mean when you say "In the theme". Are you suggesting to include some logic to change the block subject at the top of xtemplate.xtmpl?
In themes you can override...
... the output. In this case, the blocks are output by xtemplate.engine's xtemplate_block() function. You could hack it, e.g.,
(All of this is more cleanly done in PHPTemplate, where you can include such logic in templates rather than hacking the engine.)
yikes
Drupal should seriously consider an approach like patTemplate which uses XML-based templates and doesn't contain any server side logic at all.
Nevertheless, your solution will suffice for my present need--thanks!
Write a theme engine?
Drupal supports multiple theme engines--so you could consider writing and contributing one for your preferred system.
It's an interesting idea
and one that's been raised before.
If you never seen patTemplate in action you're missing out. It's a thing of beauty.
small mod
I'm checking to see if $user->full_name exists before making the change:
block object
Incidentally, the arg passed to xtemplate_block() is an object and not an array.
As such, the aforementioned lines should be:
The same for phptemplate?
Hi,
How would this be achieved for phpTemplate?
Love, Live, Laugh
Anyone on this one?
I would love to do this for phptemplate - anyone know how to do it?
Thanks!
same for phptemplate
liveoutloud2day,
I switched to phptemplate many months back and here's how to do the same.
At the top of block.tpl.php add the following php code:
The above assumes that the field "fullname" has been added to the $user object, which can be accomplished with hook_user().
one more thing
nedjo,
Where do you recommend making the function call that's responsible for loading the $user object with the full name?
Thanks again for all your help.
I'd say, offhand, in a _menu hook
in the part outside the $may_cache part:
That should do it
Good call, thanks.
Replace username in navigation block with fullname.
If anyone is looking for a complete solution to replacing the username in the navigation block with fullname here is the code I used. Since I seperated firstname and lastname they should be joined together. Place the code in the block.tpl.php as follows:
deQuindío Fitness
Thanks
This is great I have been trying to do this for a while. Can this work with LDAP integration?
Sorry, I don't know anything about LDAP
So, this give me a chance to learn about something knew.
deQuindío Fitness
which file should I edit?
Hi, may I ask which file should I edit?
Thanks.