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?

Comments

grobemo’s picture

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.png or sites/all/themes/yourtheme/images/logo.png, with no slash at the beginning.

tenek’s picture

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.

grobemo’s picture

Glad I could help. I've edited the code above to avoid misleading other people. Thanks for pointing that out.

frozone’s picture

Is there a way to do this by content type, instead of path?

Thanks.

akalata’s picture

frozone I'm guessing that switch (arg(0)) could be changed to switch ($node->type).

Wilby1976’s picture

Component: PHP Code » layout.css

Is there a way to change the URL of the logo as well?

JohnAlbin’s picture

Status: Active » Closed (fixed)