1

What I'm trying to do seems simple, and I'm sure it is, I just don't know what theme files need to be modified and how to modify them.

I want to make the user profile page display the user's first and last name (custom fields assigned to the User profile) as the title, rather than their username (which is default).

What I'm assuming can be done is intercept the title variable somewhere and change it to what I want.

How can I do this?

Cheers.

2

In Drupal 7, the template file that sets the title shown in the browser page is html.tpl.php, while the template that sets the page title is page.tpl.php.

Both the templates don't receive a variable containing the user object to which the page is referring, as those templates are used for every page. If you want to change the titles only for user pages, then you need to get the user object using menu_get_object('user'). The function returns FALSE if the currently shown page is not a user profile page; that is what happens when the viewed page is, e.g., example.com/node/1.

1

Not sure if you would be interested in using a module to do this but you can check out the Page Title module.

This module gives you granular control over the page title. You can specify patterns for how the title should be structured and, on content creation pages, specify the page title separately to the content's title.

  • I'm mostly interested in solving this using a direct theming method. However, in the event that no theming-based answers come my way within a day or so, I'll probably use this method. – Lester Peabody Jul 28 '11 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.