Roundcube Community Forum

 

Page Title Help Needed

Started by rcmmm, June 08, 2007, 07:21:22 PM

Previous topic - Next topic

rcmmm

Hi all,
I am new to RC, and have to say I LOVE it. ;D I am trying to alter a few things and the one I am currently stuck on is showing the email of a user in the title, so the title would be john@doe-Roundcube Webmail . Does anyone know how I could do this please? Any help would be greatly appreciated. Thanks!

windhood

Hi,did you get this resolved?
it is really weird, php code does not have effect in the template files (under skins/default/include or template)

rcmmm

Hi,
There may be a better way of doing it but I did it like this:

1. Find the big switch statement in program\include\rcmail_template.inc
2. Scroll thoruhg that switch statemtn untuil line 448, where you will hit this code:
    else if ($object=='pagetitle')
     {
     $task = $this->task;
     $title = !empty($this->config['product_name']) ? $this->config['product_name'].' :: ' : '';

     if (!empty($this->pagetitle))
      $title .= $this->pagetitle;
     else if ($task == 'login')
      $title = rcube_label(array('name' => 'welcome', 'vars' => array('product' => $this->config['product_name'])));
     else
      $title .= ucfirst($task);

     return Q($title);
     }

3. I simply replaced this with this:
         else if ($object=='pagetitle')
     {
     $task = $this->task;
       if ($task == 'login'){
      $title = rcube_label(array('name' => 'welcome', 'vars' => array('product' => $this->config['product_name'])));
       }
       else{
$emailaddy=$_SESSION['username'];
    $title=$emailaddy1." - Roundcube Webmail";
       }
     return Q($title);
     }

Hope that helps. Cheers!

bobmagoo

#3
I realize I'm replying to an older thread, but hopefully a few of you will find this useful.

Based on rcmmm's code but with a few tweaks, here's what I came up with.

if ($task == 'login'){
                    
$title rcube_label(array('name' => 'welcome''vars' => array('product' => $this->config['product_name'])));
                    }
                    else {
                        
$titleP1 "";
                        if (isset(
$_SESSION['username'])) {
                            
$titleP1 $_SESSION['username'];
                        } else {
                            
$titleP1 "Roundcube";
                        }
                        
$title $titleP1 " - Webmail";
                    }
                    return 
Q($title);


This takes the currently logged in user's name and sets it as the title, adding a "- Webmail", and if no user is logged in, it sets the title to Roundcube - Webmail.

My php skills are fairly limited, so any suggestions for improvement would be appreciated. I think this idea would be something worth adding to the next release.

PeterHaartsen

I made a modification similar to the one showed by rcmmm to get the username in the title. I use Roundcube 0.3.1.

I added one line to program/include/rcube_template.php (see highlighted part):

    /**
     * Getter for the current page title
     *
     * @return string The page title
     */
    public function get_pagetitle()
    {
        if (!empty($this->pagetitle)) {
            $title = $this->pagetitle;
        }
        else if ($this->env['task'] == 'login') {
            $title = rcube_label(array('name' => 'welcome', 'vars' => array('product' => $this->config['product_name'])));
        }
        else {
            $title = ucfirst($this->env['task']);
        }

       $title.=" :: ".$_SESSION['username'];

        return $title;
    }