Improving theme('username') with inspiration from Facebook
We have a handy function, theme('username') which accepts a uid and name and returns a profile link. But perhaps that function should be a bit more expressive. See below for the parameters to the equivalent Facebook function (from http://wiki.developers.facebook.com/index.php/Fb:name): * Required - int uid - The id of the user whose name to show. * Optional - bool firstnameonly - Show only the user's first name. (default value is false) - bool linked - Link to the user's profile. (default value is true) - bool lastnameonly - Show only the user's last name. (default value is false) - bool possessive - Make the user's name possessive (e.g. Joe's instead of Joe). (default value is false) - bool reflexive - Use "yourself" if useyou is true. (default value is false) - bool useyou - Use "you" if uid matches the logged in user. Setting to false doesn't work if you use the "loggedinuser" substitution for uid, since users can get freaked out by that. (default value is true) - string ifcantsee - Alternate text to display if the logged in user cannot access the user specified. (default value is [empty string]) - bool capitalize - Capitalize the text if useyou==true and loggedinuser==uid. (default value is false) Do folks think this is a good idea for Drupal core? If not, why? Could we deal with 'possesive' and 'reflexive' flags in a way that respects all languages? I know that this function can be enhanced in Contrib, but my desire is to improve the core.
Way too English centric. Many languages have no matching features. Personally I see no need to have pages personalized with my name but I do need to know if I am logged in or not. Just the presence of a logon box is sufficient for that. I really object to the hack that changes the word Navigation to my logon name that is part of core behavior. -----Original Message----- From: development-bounces@drupal.org [mailto:development-bounces@drupal.org] On Behalf Of Moshe Weitzman Sent: Monday, August 20, 2007 10:28 AM To: development@drupal.org Subject: [development] Improving theme('username') with inspiration fromFacebook We have a handy function, theme('username') which accepts a uid and name and returns a profile link. But perhaps that function should be a bit more expressive. See below for the parameters to the equivalent Facebook function (from http://wiki.developers.facebook.com/index.php/Fb:name): * Required - int uid - The id of the user whose name to show. * Optional - bool firstnameonly - Show only the user's first name. (default value is false) - bool linked - Link to the user's profile. (default value is true) - bool lastnameonly - Show only the user's last name. (default value is false) - bool possessive - Make the user's name possessive (e.g. Joe's instead of Joe). (default value is false) - bool reflexive - Use "yourself" if useyou is true. (default value is false) - bool useyou - Use "you" if uid matches the logged in user. Setting to false doesn't work if you use the "loggedinuser" substitution for uid, since users can get freaked out by that. (default value is true) - string ifcantsee - Alternate text to display if the logged in user cannot access the user specified. (default value is [empty string]) - bool capitalize - Capitalize the text if useyou==true and loggedinuser==uid. (default value is false) Do folks think this is a good idea for Drupal core? If not, why? Could we deal with 'possesive' and 'reflexive' flags in a way that respects all languages? I know that this function can be enhanced in Contrib, but my desire is to improve the core. -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.484 / Virus Database: 269.12.0/961 - Release Date: 8/19/2007 7:27 AM
On 8/20/07, Moshe Weitzman <weitzman@tejasa.com> wrote:
We have a handy function, theme('username') which accepts a uid and name and returns a profile link. But perhaps that function should be a bit more expressive.
It would be nice to have the ability to hook into the rendering of this and provide more options. E.g. I submitted a patch to buddylist that would add a (+) to add new users to your buddylist and (-) to remove them. For bio, we'd like to override the name with the title of the bio node, which in many implementations might be "Firstname Lastname". Perhaps a better way of thinking about this is to view the problem as rendering an entire "user" object, not just a link. Right now we render nodes in teaser and full views, and I know Eaton is working on more rendering contexts. Perhaps this idea overlaps with that work. -Mark
I don't know that all of the Facebook options are useful to us, and it seems like a couple might problematic for localization and internationalization. Still, it would be nice to have a some flexibility in styling user names in core. How about something like pluggable "theme-lets" or "micro-themes," so site owners can pick and choose which things they want special theming applied to, without getting a huge barrel full of unwanted extra code, sort of like enabling additional types in CCK? (Simply reading and interpreting the PHP code is a major bottleneck for any site without a PHP accelerator/code cache of some kind, especially with a large number of modules enabled. Thus, I favor finding ways to optionally include code.)
On 8/20/07, Chris Johnson <cxjohnson@gmail.com> wrote:
I don't know that all of the Facebook options are useful to us, and it seems like a couple might problematic for localization and internationalization. Still, it would be nice to have a some flexibility in styling user names in core.
How about something like pluggable "theme-lets" or "micro-themes," so site owners can pick and choose which things they want special theming applied to, without getting a huge barrel full of unwanted extra code, sort of like enabling additional types in CCK?
I think the main point was "what are the minimal set of useful items that could go into core?". If the answer is "none", then the whole thing could be done as a contrib module. -- Boris Mann Office 604-682-2889 Skype borismann http://www.bryght.com
I've been doing a lot of Facebook development and find the options for fb:name very useful. It's a great way to give a site a more personal feel and for social networking this is a big plus. When using a person's real name with fb:name I use possessive a lot. A really great FBML tag is fb:pronoun which will render he, him, himself, etc. and I use those a ton as well. I think this would be really nice for core and would fit best in profile module. I think *linked, possessive, useyou, objective, firstnameonly* are some good places to start. But for this to work we'd need a Display Name field (there is a patch for this somewhere) and an optional Gender field for pronoun stuff. Also, for people worried about internationalization...Facebook allows tons of crazy UTF-8 names so they have a way to deal with all these situations. What that is, I'm not sure, but we could just emulate what they do. -R Boris Mann wrote:
On 8/20/07, Chris Johnson <cxjohnson@gmail.com> wrote:
I don't know that all of the Facebook options are useful to us, and it seems like a couple might problematic for localization and internationalization. Still, it would be nice to have a some flexibility in styling user names in core.
How about something like pluggable "theme-lets" or "micro-themes," so site owners can pick and choose which things they want special theming applied to, without getting a huge barrel full of unwanted extra code, sort of like enabling additional types in CCK?
I think the main point was "what are the minimal set of useful items that could go into core?". If the answer is "none", then the whole thing could be done as a contrib module.
I think this would be really nice for core and would fit best in profile module. I think linked, possessive, useyou, objective, firstnameonly are some good places to start. But for this to work we'd need a Display Name field (there is a patch for this somewhere) and an optional Gender field for pronoun stuff.
Again: not all languages work like English. French for example has a different possessive construction using two words: "le livre de kkaefer" instead of "kkaefer’s book". Konstantin Käfer — http://kkaefer.com/
Op maandag 20 augustus 2007, schreef Moshe Weitzman:
Do folks think this is a good idea for Drupal core? If not, why?
Good idea indeed. The idea of hving flags (useyou) that toggle behaviour is really nice too.
Could we deal with 'possesive' and 'reflexive' flags in a way that respects all languages?
I'd say, that even if this is too hard (and I think it will be, In Dutch, e.g. this is really hard to program) we could ditch these two grammatical flags and still implement the others. Nice find! bèr -- Drupal, Ruby on Rails and Joomla! development: webschuur.com | Drupal hosting: www.sympal.nl
On 8/20/07, Moshe Weitzman <weitzman@tejasa.com> wrote:
We have a handy function, theme('username') which accepts a uid and name and returns a profile link. But perhaps that function should be a
Actually, it accepts only a single argument but that is beside your point. function theme_username($object)
Do folks think this is a good idea for Drupal core? If not, why? Could we deal with 'possesive' and 'reflexive' flags in a way that respects all languages? I know that this function can be enhanced in Contrib, but my desire is to improve the core.
I don't see the point of implementing this in core unless it would be needed and used in core. It would already be possible to do this in a theme and your module with function phptemplate_username($object, $args = array()) So the question is if or how this flexibility could be needed in core. You provide no examples. Cheers, Chris
Op dinsdag 21 augustus 2007, schreef beerfan:
It would already be possible to do this in a theme and your module with
function phptemplate_username($object, $args = array())
So the question is if or how this flexibility could be needed in core. You provide no examples.
What is not passed along is information such as $user->myself (flag to say: I am passing you the same user that the page is served to) things like that. I usuually create all such flags and variables (including $user->nicename, compiled from certain profile fields) in the phptemplate variable. But the thing is, that most of these flags, and namespaces require a lot of business logic. Therefore having more $user->thingies is IMO a good thing. Bèr -- Drupal, Ruby on Rails and Joomla! development: webschuur.com | Drupal hosting: www.sympal.nl
I find these to be interesting and possibly very compelling additions. Even if not every language will be able to utilize the flags, those languages can simply fall back on current default behavior. Languages that can leverage the flags will be able to provide a richer experience. Plus, adopting elements of the fb API might make it one small step easier to write fb applications. At this point it should be pretty clear to everybody that this is an important part of Drupal's future.
participants (10)
-
beerfan -
Boris Mann -
Bèr Kessels -
Chris Johnson -
Konstantin Käfer -
Mark Fredrickson -
Moshe Weitzman -
Rob Barreca -
Robert Douglass -
Walt Daniels