Title change

rockwright - July 28, 2009 - 19:17
Project:Invite
Version:6.x-2.0-alpha1
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi,

I’m looking for a way to change the title of the invitation page in the profile page from “My Account” to the user’s username as shown in the attachments. Can this be done by views or would I need to modify the code? Thank you for the support.

AttachmentSize
SDC10392.JPG585.9 KB
SDC10394.JPG588.44 KB

#1

hefox - August 9, 2009 - 01:03

I've had to do something similiar, in the end I ended up overiding it in the theme

here's a code snippit (needed it on several pages).

<?php
function themename_preprocess_page(&$vars) {
   
$uid = arg(1);
    if (
arg(0)=='user' && $uid && is_numeric($uid) && $account = user_load($uid)) {
       
// due the various setting of drupal_set_title need to manually override the title for user pages.
       
$title_save= $vars['title'] ;
       
$new_title = $account->name;
                 
// setting the browser title
       
$vars['head_title'] =  $new_title . ' | ' . $vars['site_name'];
               
// setting the page title
       
$vars['title'] = $new_title;
    }
}
?>

#2

rockwright - August 10, 2009 - 20:19

Would the above code go into template.php?

#3

hefox - August 10, 2009 - 20:25

oops, yes it would

#4

rockwright - September 18, 2009 - 09:38

You said you needed the snippet in several pages, what pages would those be? I tried inserting that code in the template file but it still didn't render what I wanted.

#5

hefox - September 18, 2009 - 13:09

Hm, weird I have it working on two pages. What base them you using? Did you change themename to your theme's name?

On mine it changes the title of anything with the url user//
ie

user/1/edit
user/1/view (aka user/1)
user/1/notifications
user/1/invite
user/1/contact

 
 

Drupal is a registered trademark of Dries Buytaert.