Hello,

I would like to change the category separator for page titles from | to ::

eg: this current page is Submit forum topic | drupal.org

I would like to change all pages to use :: so it will be Submit forum topic :: drupal.org

What file do I need to modify to achieve this?

Comments

zroger’s picture

$head_title (the variable that contains the page title) is set like this in phptemplate.engine:

  // 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', '');
    }
  }

  $variables = array(
    ...
    'head_title'          => implode(' | ', $head_title),
    ...
  ); 

So you can override this in your themes template.php file in a similar fashion in the _phptemplate_variables() function.

function _phptemplate_variables($hook, $vars = array()) {
  switch($hook){
    case 'page':
      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', '');
      }
      $vars['head_title'] = implode(' :: ', $head_title),
      break;
  }
  return $vars;
}
paolability’s picture

This looks good but how would I swap two elements (page title and site name) for the home page only (which happens to be of a custom node type 'homepage') in 4.6?

Are the node attributes available in _phptemplate_variables ?

ellanylea’s picture

Thank you for sharing this code snippet. When I implemented it, I got some errors, it was just a matter of closing one of the if { } and changing a comma to a semi-colon. Here is the corrected code, runs smoothly with Drupal 4.7.

function _phptemplate_variables($hook, $vars = array()) {
  switch($hook){
    case 'page':
      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', ''); }
      }
      $vars['head_title'] = implode(' :: ', $head_title);
      break;
  }
  return $vars;
}

-------------------------------------------------
AdAstra.ca - Optimze the Web. Optimze the World.

creazion_dev’s picture

Hi firmbit,

in the node.tpl.php file you should replace the following line:

<span class="taxonomy"><?php print $terms ?></span>

with this lines:

<span class="taxonomy">
<?php
  foreach($node->taxonomy as $tid => $taxo) 
    $taxo_links[] = l($taxo->name,'image/tid/'.$taxo->tid, array('title' => $taxo->name));
		
  print implode(' &middot; ',$taxo_links);
?>
</span>

Replace ' &middot; ' with your preferd delimiter.

---------------------------------------------
last projects: www.happy-faces.de - www.3p-consulting.com

creazion_dev’s picture

Uups, I misunderstood your question. I hope someone other can use it.

---------------------------------------------
last projects: www.happy-faces.de - www.3p-consulting.com

marknunney’s picture

The Page title module should do the job. See:

http://drupal.org/project/page_title