Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
grobemo CreditAttribution: grobemo commentedThe 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:
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
orsites/all/themes/yourtheme/images/logo.png
, with no slash at the beginning.Comment #2
tenek CreditAttribution: tenek commentedThanks!
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.
Comment #3
grobemo CreditAttribution: grobemo commentedGlad I could help. I've edited the code above to avoid misleading other people. Thanks for pointing that out.
Comment #4
frozone CreditAttribution: frozone commentedIs there a way to do this by content type, instead of path?
Thanks.
Comment #5
akalata CreditAttribution: akalata commentedfrozone I'm guessing that
switch (arg(0))
could be changed toswitch ($node->type)
.Comment #6
Wilby1976 CreditAttribution: Wilby1976 commentedIs there a way to change the URL of the logo as well?
Comment #7
JohnAlbin