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.
I've always disliked that I cannot chose which user information is displayed to the outside world. I often prefer to show "Firstname Lastname" rather than a often cryptic username. I could of course change this display in the node and comment functions of my theme, but then it would be confusing if the same user essentially has another name in the user search or the admin interface. Therefore I propse to make format_name a themabel function. Patch attached.
Comment | File | Size | Author |
---|---|---|---|
#9 | theme_username_0.patch | 20.14 KB | killes@www.drop.org |
#4 | theme_username.patch | 20.05 KB | killes@www.drop.org |
theme_format_name.patch | 20.39 KB | killes@www.drop.org | |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedmakes sense to me.
Comment #2
Steven CreditAttribution: Steven commentedtheme('format_name') is a bit weird... why not have theme('name') ?
Oh and this might be a good time to change it so that it uses drupal_substr() and drupal_strlen() to cut off the username. This would mean the visual string length before chopping is more consistent.
Comment #3
Dries CreditAttribution: Dries commentedBetter would be
theme('username')
, I think. "format_" is redundant in combination with "theme", but "name" is a bit too generic a name, I'd say. Otherwise it looks good. Not tested though.Comment #4
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedOk, implemented the suggested changes.
Since it did get such a warm welcome, how about doing the same to the format_date function and removing the various settings (everythign but time zone) associated with it?
Comment #5
Bèr Kessels CreditAttribution: Bèr Kessels commentedI tried this patc hon a dutch localised system. It works as expected. I like it.
A question though, which also applies to the recently introduced patch to move date settings to locales:
Unglish native speakers will now need to enable localisation, just for the sake of changing small things like the date, or, in this case, the name.
However, personally I do not really mind that, since I use locale on all my sites anyway. But others might not like that (performance) penalty. Ideas?
Comment #6
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedthanks for testing.
Why do you think that you'd need to enable locale.module for changing the name?
You need to implement a themable function in your theme, that's it.
Comment #7
Bèr Kessels CreditAttribution: Bèr Kessels commentedNM. just me being confused. I have been workingon some complex (multilinugal) things lately. Somehow that flooded my mind. I guess.
I tested this, to theme an icon of teh user (avatar) in front of the usernames. on newsphoto.nl we want to present everyone with images. (teh dev site is not public, so I cannot show the result, yet)
Comment #8
Dries CreditAttribution: Dries commentedPatch no longer applies.
Comment #9
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedupdated
Comment #10
Dries CreditAttribution: Dries commentedCommitted to HEAD. Please update the documentation.
Comment #11
(not verified) CreditAttribution: commentedComment #12
(not verified) CreditAttribution: commentedComment #13
(not verified) CreditAttribution: commentedComment #14
(not verified) CreditAttribution: commentedComment #15
(not verified) CreditAttribution: commented