Author Topic: Page Title Help Needed  (Read 7850 times)

Offline rcmmm

  • Newbie
  • *
  • Posts: 3
Page Title Help Needed
« on: June 08, 2007, 07:21:22 PM »
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!

Offline windhood

  • Newbie
  • *
  • Posts: 2
Re: Page Title Help Needed
« Reply #1 on: July 24, 2007, 04:16:52 AM »
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)

Offline rcmmm

  • Newbie
  • *
  • Posts: 3
Re: Page Title Help Needed
« Reply #2 on: July 24, 2007, 06:06:35 AM »
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!

Offline bobmagoo

  • Newbie
  • *
  • Posts: 1
slight tweaking
« Reply #3 on: July 10, 2009, 07:35:22 PM »
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.
« Last Edit: July 10, 2009, 07:59:13 PM by bobmagoo »

Offline PeterHaartsen

  • Newbie
  • *
  • Posts: 2
Page Title Help Needed
« Reply #4 on: February 27, 2010, 10:18:03 AM »
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;
    }