Renaming site per section error

RichardD's picture

Originally posted on the Drupal forum:

Any reason why I get an error when I implement this: http://drupal.org/node/154099

<?php
/**
* This snippet overrides the logo and site name when users
* are viewing certain sections of your site.*/

function _phptemplate_variables($hook, $variables = array()) {
switch ($hook) {
case 'page':
if ((arg(0) == 'blog')) {// changes the logo and site name when viewing blogs
$variables['site_name'] = 'blog section name'; // change the site name
$variables['logo'] = '/path/to/newlogo/logo.png'; // change the site logo
}
if ((arg(0) == 'image')) { // changes the logo and site name when viewing images
$variables['site_name'] = 'user section name'; // change the site name
$variables['logo'] = '/path/to/newlogo/logo.png'; // change the site logo
}
if ((arg(0) == 'admin')) { // changes the logo and site name when viewing admin pages
$variables['site_name'] = 'admin section name'; // change the site name
$variables['logo'] = '/path/to/newlogo/logo.png'; // change the site logo
}
if ((arg(0) == 'product')) { // changes the logo and site name when viewing product pages
$variables['site_name'] = 'admin section name'; // change the site name
$variables['logo'] = '/path/to/newlogo/logo.png'; // change the site logo
}
break;
}

return $variables;
}
?>

Here's the error:

Fatal error: Cannot redeclare _phptemplate_variables() (previously declared in /home/sites/example.co.uk/public_html/sites/all/themes/zen/template.php:155) in /home/sites/example.co.uk/public_html/sites/all/themes/zen/template.php on line 363

All I want to do is change the blog. So then I went to line 155 and just put this piece of code in instead of all of the above:

function _phptemplate_variables($hook, $variables = array()) { (-----------this was on line 155 so copied over-----)
switch ($hook) {
case 'page':
if ((arg(0) == 'blog')) {// changes the logo and site name when viewing blogs
$variables['site_name'] = 'blog section name'; // change the site name
$variables['logo'] = '/path/to/newlogo/logo.png'; // change the site logo
}
break;
}

return $variables;
}

and got a syntax error } on line 320