How To Install Page Title Module in Zen 0.6

I am not a coder and if you aren't either than this post is perfect for you. You should be able to follow this even if you are fairly new to Drupal. It took me a minute to figure out how to get this thing working, and I'll show you EXACTLY how to do it. First you need to follow the file path. Go to your /themes folder, then the /zen folder, and then you need to open up the template.php file.

You then need to look for the following chunk of code:

function _phptemplate_variables($hook, $vars = array()) {
  switch ($hook) {
    // Send a new variable, $logged_in, to page.tpl.php to tell us if the current user is logged in or out.
    case 'page':

      // get the currently logged in user
      global $user;
    

      // An anonymous user has a user id of zero.     
      if ($user->uid > 0) {
        // The user is logged in.
        $vars['logged_in'] = TRUE;
      }
      else {
        // The user has logged out.
        $vars['logged_in'] = FALSE;
      }

Then you need to add the follow code in:

    // These are the only important lines
    if (module_exists('page_title')) {
      $vars['head_title'] = page_title_page_get_title();
}

You need to add the code so that code looks like this:

function _phptemplate_variables($hook, $vars = array()) {
  switch ($hook) {
    // Send a new variable, $logged_in, to page.tpl.php to tell us if the current user is logged in or out.
    case 'page':

    // These are the only important lines
    if (module_exists('page_title')) {
      $vars['head_title'] = page_title_page_get_title();
  }

      // get the currently logged in user
      global $user;
    

      // An anonymous user has a user id of zero.     
      if ($user->uid > 0) {
        // The user is logged in.
        $vars['logged_in'] = TRUE;
      }
      else {
        // The user has logged out.
        $vars['logged_in'] = FALSE;
      }

You may have an issue getting your home page title tag to change and that is because it is wired to your site slogan. Go into the site information page and change the site slogan. Once you do this the title tag on your home page will now incorporate the site slogan into the title tag.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options