I'm using the Page Title Module, which normally requires a small modification to the theme template to show the desired (over-ridden) title in the head. Here's the code:

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

Unfortunately, I'm working on a site that's using the Chameleon Marvin theme, a non-template theme. How do I modify the chameleon.theme file in the appropriate place to call the page title from the module and print that in the head, instead?

I'm looking at this line from the chameleon theme:

 $output .= " <title>". ($title ? strip_tags($title) ." | ". variable_get("site_name", "Drupal") : variable_get("site_name", "Drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n";
  

Comments

2houseplague’s picture

The solution was I replaced the above line from the chameleon.theme file with this one:

$output .= "<title>". page_title_page_get_title() ."</title>\n";

Proton Cannon

jdr7181’s picture

When I replace the first portion of this:

$output .= " <title>". ($title ? strip_tags($title) ." | ". variable_get("site_name", "Drupal") : variable_get("site_name", "Drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n";

with:

$output .= "<title>". page_title_page_get_title() ."</title>\n";

so that it looks like this:

$output .= "<title>". page_title_page_get_title() ."</title>\n"; variable_get("site_name", "Drupal") : variable_get("site_name", "Drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n";

I get the following error:

Parse error: syntax error, unexpected ':' in /home/spaceadv/public_html/themes/chameleon/chameleon.theme on line 33

Can someone help me with this syntax? That colon is in the same place in both examples. What is it about the change that makes that colon use bad syntax?

Jack

Here's a larger excerpt from my chameleon.theme file from which the above is derived:

function chameleon_page($content, $show_blocks = TRUE, $show_messages = TRUE) {
  $language = $GLOBALS['language']->language;
  $direction = $GLOBALS['language']->direction ? 'rtl' : 'ltr';

  if (theme_get_setting('toggle_favicon')) {
    drupal_set_html_head('<link rel="shortcut icon" href="'. check_url(theme_get_setting('favicon')) .'" type="image/x-icon" />');
  }

  $title = drupal_get_title();

  // Get blocks before so that they can alter the header (JavaScript, Stylesheets etc.)
  $blocks_left = theme_blocks('left');
  $blocks_right = theme_blocks('right');

  $output  = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
  $output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"$language\" xml:lang=\"$language\" dir=\"$direction\">\n";
  $output .= "<head>\n";
  $output .= drupal_get_html_head();
  $output .= " <title>". ($title ? strip_tags($title) ." | ". variable_get("site_name", "Drupal") : variable_get("site_name", "Drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n";
  $output .= drupal_get_css();
  $output .= drupal_get_js();
  $output .= "</head>";
  $output .= "<body>\n";
  $output .= " <div id=\"header\">";

  if ($logo = theme_get_setting('logo')) {
    $output .= "  <a href=\"". url() ."\" title=\"". t('Home') ."\"><img src=\"$logo\" alt=\"". t('Home') ."\" /></a>";
  }
  if (theme_get_setting('toggle_name')) {
    $output .= "  <h1 class=\"site-name title\">". l(variable_get('site_name', 'drupal'), "") ."</h1>";
  }
  if (theme_get_setting('toggle_slogan')) {
    $output .= "  <div class=\"site-slogan\">". variable_get('site_slogan', '') ."</div>";
  }
jdr7181’s picture

You have to replace the whole section with that one line, not just the top line of that section.

Jack