Upon the creation of a book page, I supply the Page Title I want, but the browser still shows the Node's Title instead of the one I specify.

I looked around to see if other people I the same problem. I did see one thread wherein it was suggested to add the following code to my template.php:

if (module_exists('page_title')) {
$vars['head_title'] = page_title_page_get_title();
}

which I did. No dice.

I am running Drupal 5.3 in a folder (not at root) of my website

Thanks in advance!
Beth

Comments

tone1’s picture

Can't get it to work, either it's not working or I am not understanding that there is more needed to do. Is this a Drop in Module (Wham Bam, Enable?) or is this a Drop in Module (Now Break out the tools?) Is there more than just dropping it in to the Module folder, Enable, Configure = Your set to go? If it does require more, can you please explain the process a smigg more clearly. I do apologize if this sounds rude, I don't mean it too (I=No0ber).

nicholasthompson’s picture

I dont suppose you read the README.TXT which was provided in the modules folder did you?

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/page_title/...

Basically, once the module is enabled you MUST go into your theme's template.php file and add the lines which set the $vars['head_title']. Unfortunately the head_title is one of the few things that isn't exposed very well.

You must add these lines inside the _phptemplate_variables function but ONLY when the $hook is 'page'... So your function MIGHT look something like this...

function _phptemplate_variables($hook, $vars) {
  if ($hook == 'page') {

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

  }
  return $vars;
}

If you guys are still having problems, please post back. The module DOES work - you just need to make sure you've read the instructions first ;-)

bitsyboo’s picture

Um. Yeah. It works now. *sheepish grin*

RTFM -- I really need to be better about that. Thanks for the help and patience!

nicholasthompson’s picture

Status: Active » Fixed

No probs - glad its working for you now :)

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

bigsend’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

I don't see a _phptemplate_variables function. I do use the Bluemarine theme (come stock with Drupal 5.7), so I guess I'd be looking for bluemarine_variables but I don't see that either.

There is a page.tpl.php, node.tpl.php, comment.tpl.phph, box.tpl.php, block.tpl.php file. I assume we'd work with the page.tpl.php.

I do not see where in the code we copy and paste the

<?php
function _phptemplate_variables($hook, $vars) {
  if ($hook == 'page') {

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

  }
  return $vars;
}
?>

Unless we just stick it in the < title > < / title > section, I don't see where to put it.

-Thanks
BigSend
http://bigsendworld.com
http://mydrupaladventures.com (this is the blog I am working with now to implement it)

jbrauer’s picture

Status: Postponed (maintainer needs more info) » Fixed

@bigsend In the case where you don't have an existing _phptempate_variables() function you should add the entire code snippet from your comment (just leave out the ?php tags itself.

bigsend’s picture

Add it... to where?...

jbrauer’s picture

To the template.php file.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

mindgarden’s picture

Why I still can't get it to work after putting that code in template.php?

I'm using the Acquia Marina theme on D6.

Btw, is that code missing the line: $vars = array(); ?