hi guys,

on my side i use nodeprofile to show the realname of a user on different places.

i also want to see the realname from my nodeprofile on the contact form.

why i dont see the realname? why i see the username?

on many other sections / modules i see the themed username automaticly.

regards

Lausch

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Title: show themed username instead of username (login name) ? » Use theme_username() in the personal contact form
Version: 5.7 » 7.x-dev

Seems valid. Marking to the current version of Drupal to patch then backport.

Dave Reid’s picture

Status: Active » Needs review
FileSize
1019 bytes

Patch ready for review.

Status: Needs review » Needs work

The last submitted patch failed testing.

Dave Reid’s picture

Status: Needs work » Needs review
FileSize
1020 bytes

My bad.

j.somers’s picture

Status: Needs review » Reviewed & tested by the community

Patch works fine for me.

dawehner’s picture

i tested the patch also and it works well.

i'm just wondering why using "<" instead of "<" does not work, can someone explain this?

dropcube’s picture

Simple patch, confirming RTBC.

webchick’s picture

Version: 7.x-dev » 6.x-dev

Looks good. Committed to HEAD. Thanks! Moving back to 6.x for consideration.

@dereine: We use < because this is output to the browser, and we're required to encode entities or else we break XHTML compliance.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Did not apply to Drupal 6, but rerolled and committed.

I'd like to point out however that the page title is still the user's account name, not the real name even if theme_username() is overriden in other places. Since the theme function generates links if the user can view profiles, this cannot be used directly to set the page title (unless we want the page title to have a link of course).

webchick’s picture

Version: 6.x-dev » 7.x-dev
Category: feature » bug
Status: Fixed » Active
Issue tags: +Novice

Hm. Good point.

Moving back to 7.x, since we can at least fix this here. Also tagging as novice, since I imagine this is probably easy to fix. :) http://api.drupal.org/api/function/contact_user_page/7 looks like a good place to start; else maybe by adding a 'title callback' to the menu item like 'user/%user_uid_optional' has.

wulff’s picture

FileSize
831 bytes

I wonder if we could simply use filter_xss or something similar to strip the <a> tags from the return value of theme_username?

dixon_’s picture

Status: Active » Reviewed & tested by the community

I've tested the patch in #11 and it works fine on a fresh D7 installation.

I still don't know if this is the preferred way to approach the problem. But this feels like a simpler solution than adding a title callback to the menu item. Am I right?

webchick’s picture

Hm. I think this will end up with <a href="..."> showing up in your <title> tags. I've asked Peter to take a look at this as well, since he's more well-versed in the D7 version of drupal_set_title().

webchick’s picture

Status: Reviewed & tested by the community » Needs review
pwolanin’s picture

using filter_xss() will certainly be safe if that's the goal. By passing in no allowed tags, it will effectively strip all tags, plus do some other checks.

In fact, we will also run it through strip_tags() in http://api.drupal.org/api/function/template_preprocess_page/7 for the head title so the worry is not really that tags will end up in the <title> tag.

pwolanin’s picture

Status: Needs review » Reviewed & tested by the community

Probably this is fine for now - however, we should possibly as a separate patch add a parameter to theme_username to request the non-link form.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Hm. So when I actually tried this patch out myself, I found it a bit jarring.

I overrode the theme_username() function like so:

function garland_username($object) {
  return l('bananas', 'node/' . $object->uid);
}

user/1/view: page title is "a"
user/1/edit: page title is "a"
user/1/tracker: page title is "a"
user/1/contact: page title is "bananas"

I'm thinking we'll want to escalate this to a larger "we should use the username coming out of theme_username() in user/X/Y" issue since fixing it only in Contact module looks very bizarre.

I've created a separate issue here for this: #464888: Use theme('username') in user profile page titles. I'm going to mark this issue fixed because the patch back in #4 was committed, but hopefully we can get some resolution over there for the larger user profile mis-match issue.

Status: Fixed » Closed (fixed)
Issue tags: -Novice

Automatically closed -- issue fixed for 2 weeks with no activity.