Front page <TITLE> tag change?

mediafrenzy - November 9, 2005 - 23:49

Hi all, after much fruitless searching I thought I'd ask the collective how I should go about reversing the SITENAME / SLOGAN in the TITLE tag for the front page of my drupal site? I'm using Kubrick phptemplate if that makes any difference?

At the moment it is in this format :

MYSITENAME | My sites Slogan Text

I'm wanting it to be:

My sites Slogan Text | MYSITENAME

I'm guessing it'll be an incredibly simple solution, but I cannot for the life of me find any info on how to do it!

Thanks in advance.

The solution

mediafrenzy - November 10, 2005 - 06:12

Well as I suspected it was very simple to do, though for a non-programmer it took a bit of finding ;)

It may be painfully simple to many of you, but I'm sure this will help some others sometime somewhere!

For anyone interested, I simply edited the phptemplate.engine file which is found here :

/themes/engines/phptemplate/phptemplate.engine

I just edited the section titled:

$vars = array(

And made the following changes:

OLD CODE
'head_title'          => (drupal_get_title() ? strip_tags(drupal_get_title()) .' | '. variable_get('site_name', 'drupal') : variable_get('site_name', 'drupal') .' | '. variable_get('site_slogan', '')),

NEW CODE
'head_title'          => (drupal_get_title() ? strip_tags(drupal_get_title()) .' | '. variable_get('site_name', 'drupal') : variable_get('site_slogan', 'drupal') .' | '. variable_get('site_name', '')),

This results in unchanged title tags through your site except for the front page (as far as I can tell so far anyways!).

The front page title tag is now "Your Site Slogan Here | Your Site Name"

The Solution - for xtemplate

januario - December 5, 2005 - 06:26

I wanted to switch around the order of the page title as well and found this post. I'm using xtemplate, so the change above didn't help, so I looked for it myself and changed the following...

themes/engines/xtemplate/xtemplate.engine

at line ~114

code...

function xtemplate_page($content) {
  global $xtemplate;

  // Construct page title
  if (drupal_get_title()) {
    $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'drupal'));
  }
  else {
    $head_title = array(variable_get('site_name', 'drupal'));
    if (variable_get('site_slogan', '')) {
      $head_title[] = variable_get('site_slogan', '');
    }
  }

from...

    $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'drupal'));

to...

    $head_title = array(variable_get('site_name', 'drupal'), strip_tags(drupal_get_title()));

My change was for non-front pages to display "Your Site Name | Page Title", not the same change requested above.

replace tags in <TITLE> with space

amcho - December 20, 2005 - 16:15

Thanks for pointing me in the right direction, I made a change reproduced below to replace a
tag in my title with a space (hope it is of use to someone).

.

/**
* modified December 2005 by amcho to replace any HTML tags in the title by space
* new function; Replace_Tags($text)
*/

function Replace_Tags($text) {
  $text=preg_replace('/</',' <',$text);
  $text=strip_tags($text);
  return $text;

}

/**
* modified December 2005 by amcho to
* use new function; Replace_Tags($text) instead of strip tags
*/

function xtemplate_page($content) {
  global $xtemplate;

  // Construct page title
  if (drupal_get_title()) {
    $head_title = array(Replace_Tags(drupal_get_title()), Replace_Tags(variable_get('site_name', 'drupal')));
  }
  else {
    $head_title = array(Replace_Tags(variable_get('site_name', 'drupal')));
    if (variable_get('site_slogan', '')) {
      $head_title[] = variable_get('site_slogan', '');
    }
  }

mod to phptemplate.engine to clear <BR> tag in title

amcho - December 21, 2005 - 14:47

The same chage can be applied to phptemplate.engine:
just after $vars = array(
change the head-title line as follows:

'head_title'          => (drupal_get_title() ? Replace_Tags(drupal_get_title()) .' | '. Replace_Tags(variable_get('site_name', 'drupal')) : Replace_Tags(variable_get('site_name', 'drupal')) .' | '. variable_get('site_slogan', '')),

 
 

Drupal is a registered trademark of Dries Buytaert.