I'm creating the theme with two styles, dark and light. User can choose which style he wants in theme settings. My default theme logo is in the root of the theme.

Now I want to change default logo according to choosen style, so if the user choose dark style and doesn't set logo image, default logo is logo.png form theme root, but if user choose light style and doesn't set logo image, default logo is logo_light.png from theme root.

How can I override default logo according to result from theme_get_setting?

3 Answers 3


A cleaner solution would be using your theme hook_preprocess_page, for example in a multi skin theme i have:

function mytheme_preprocess_page( &$vars)
    //-> skin name, use default logo?, show logo?
    $skin = theme_get_setting("skin");
    $default_logo = theme_get_setting("default_logo");
    $toggle_logo = theme_get_setting("toggle_logo");

    $url = file_create_url(drupal_get_path('theme', 'mytheme'));

    if( $default_logo && $toggle_logo)
        if( empty($skin)) $vars['logo'] = "$url/logo.png"; //default style logo
        else              $vars['logo'] = "$url/skins/$skin/logo.png";


then inside the page.tpl just the standard

<div id="header-logo">
   <?php if( $logo): ?>
      <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
   <?php endif; ?>

I think you can by adding algorythm like this:

<div id="logo">
  <a href="<? print $front_page; ?>"><img src="<? if (theme_get_setting(theme)=="dark") print $logo; else print $logo_light; ?> border="0" alt="<? print $site_name; ?>"></a>
  • thanks for you answer, but what happens when user set custom logo in theme settings and choose light style? probbably the user's logo won't render but my logo_light.png will...
    – mixerowsky
    Commented May 9, 2015 at 12:56
  • you should give the link to your base theme to look the code. or give the archive of your theme as it is now.
    – tlito
    Commented May 9, 2015 at 13:03

I fix it. I just check if the default_logo checkbox is checked. There is my code:

<div class="logo"><a class="logo-a" href="<?php print $base_url; ?>">
<?php if(theme_get_setting('default_logo') == '1' && theme_get_setting('style') == 'light'): ?>
src="<?php print base_path() . drupal_get_path('theme', 'my_theme'); ?>/logo_light.png"/></a>
<?php else: ?>
src="<?php print render($logo); ?>"/></a>
<?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.