Posted by firmbit on August 7, 2006 at 8:24pm
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
head_title
$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;
}
head_title change for the home page only
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 ?
Override default $head_title
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.
---------------------------------------------------
AdAstra.ca - Optimize the Web. Optimize the World.
Use the node.tpl.php
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(' · ',$taxo_links);
?>
</span>
Replace
' · 'with your preferd delimiter.---------------------------------------------
last projects: www.happy-faces.de - www.3p-consulting.com
Uups
Uups, I misunderstood your question. I hope someone other can use it.
---------------------------------------------
last projects: www.happy-faces.de - www.3p-consulting.com
Page title module
The Page title module should do the job. See:
http://drupal.org/project/page_title