change logo based on path

change logo based on path

6 posts / 0 new
Last post
pbidwell's picture
pbidwell
Points: 0
change logo based on path

I've found the following about changing the site logo based on URL paths: http://drupal.org/node/493594

However, after updating the code with the correct path alias and logo path (and flushing the cache), I am not able to get the different logo to appear. Is this code the right approach for doing something like this in 6.x?

So, www.example.com/section would be

switch (arg(0)) {
case 'section':
$vars['logo'] = 'sites/default/files/logo-section.png';
break;
}

Thanks,
Paul

Status: 
Resolved
cgordon's picture
charlie.gordon
Points: 0

Hi Paul,

Can you tell me which theme you're using, and paste your entire preprocess function here? If you're using a custom theme, please upload your page.tpl.php file here.

Thanks!
Charlie

Brenda Boggs's picture
brenda.boggs
Points: 0

Paul,

Check as to what arg(0) actually is. It's the system path, not the aliased path, so it should appear on the default /blog page but not if you are expecting it to show up on a particular node. Also, please confirm that $logo is being printed in your page.tpl.php as normal.

Thanks,
Brenda Boggs
Acquia Client Advisory Team

Brenda Boggs
Acquia Client Advisory Team

pbidwell's picture
pbidwell
Points: 0

Hi Brenda,

Thanks for pointing that out. The argument does pull the different logo based on the system path (node). So how could I pull the argument for the alias to make the switch? There is a related post (http://drupal.org/node/838508) but I don't know to implement.

Also, $logo is printing normally.

Thanks,
Paul

pbidwell's picture
pbidwell
Points: 0

Hi Charlie,

I am using a custom theme. page.tpl.php code is attached. Here is the preprocess function:

function aca_preprocess_page(&$vars) {

// apply class to node pages that are categorized by audience vocabulary
if ($vars['node']) {
$class = aca_get_node_color_class($vars['node']);
if ($class) {
$vars['body_classes'] .= ' '. $class;
}
}

// custom logo based on path
switch (arg(0)) {
case 'blog':
$vars['logo'] = 'sites/default/files/logo-blog.png';
break;
}

// Add conditional styles
$ie6 = '

';
$ie7 = '

';
$vars['styles'] .= $ie6 . $ie7;

// Add span markup to primary links
foreach ($vars['primary_links'] as $key => $value) {
$vars['primary_links'][$key]['title'] = ''. $vars['primary_links'][$key]['title'] .'';
$vars['primary_links'][$key]['html'] = TRUE;
}
}

Thanks,
Paul

pbidwell's picture
pbidwell
Points: 0

Hello,
I was wondering if you have any advice on how to implement this based on the code I provided. Any help would be greatly appreciated.

Thank you,
Paul