Change site logo variable based on path
tenek - June 16, 2009 - 22:21
| Project: | Zen |
| Version: | 6.x-1.0-beta3 |
| Component: | PHP Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Can anyone provide some help on how to change the site logo based on the path?
I tried these instructions: http://drupal.org/node/154099, but nothing happens (i.e. the logo does not change). I'm wondering if I need to do something different because of using zen.
Any advice?

#1
The basic idea of those instructions is correct. I don't know anything about the _phptemplate_variables function they're using. (It doesn't seem to be documented.) I'd suggest finding the YOURTHEME_preprocess_page function in your template.php file and adding the following to it:
<?php
function YOURTHEME_preprocess_page(&$vars) {
// Keep whatever other code is in this function
// Add the following
switch (arg(0)) {
case 'blog':
$vars['logo'] = 'path/to/some/logo.png';
break;
case 'admin':
$vars['logo'] = 'path/to/another/logo.png';
break;
// etc.
}
}
?>
If you're not familiar with it, arg returns bits of the path. So, arg(0) returns the first part of the path. For instance, if the page's URL is www.yoursite.com/node/1981, arg(0) returns 'node' and arg(1) returns '1981'.
Report back on whether that works, and if it doesn't, we'll keep working.
EDIT: I removed the leading slash in the logo path above, as per tenek's comment (#2) below. The path should be something like
sites/default/files/logo.pngorsites/all/themes/yourtheme/images/logo.png, with no slash at the beginning.#2
Thanks!
That worked great except that I had to remove the slash before the path (i.e. sites/default/files/logo.png not /sites/default...), which is something I should have known anyways.
#3
Glad I could help. I've edited the code above to avoid misleading other people. Thanks for pointing that out.
#4
Is there a way to do this by content type, instead of path?
Thanks.