Magento – Change Magento Header Logo to link to an external site in a multiple store account

multistore

I have multiple magento stores set up. I need to change only one of the stores' header logo to link to an external website. How do I do that?

I know where the header is:

app/design/frontend/default/[YOUR TEMPLATE]/template/page/html/header.phtml

and I know link is in this strip:

<?php if ($this->getIsHomePage()):?>
        <h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
        <?php else:?>

If I change it here, it will change all of the logos on the other stores as well. I only want to change the logo link of one store specifically.

Best Answer

The short and ugly version is to hard code the id of the website and make an if statement in the template.

<?php if (Mage::app()->getWebsite()->getId() == 4) : ?>
    Special logo and link here
<?php else : ?>
    Default behavior here
<?php endif;?>

The long an clean version is to add a configuration flag with scope website (or store view) and if that is set to 'yes' then display the custom logo and link.
Add something like this in system.xml

<config>
    <sections>
        ...
            <web>
                 <groups>
                     <custom_header translate="label">
                         <label>Custom header</label>
                         <frontend_type>text</frontend_type>
                         <sort_order>100</sort_order>
                         <show_in_default>1</show_in_default>
                         <show_in_website>1</show_in_website>
                         <show_in_store>1</show_in_store>
                         <fields> 
                             <custom_link translate="label">
                                 <label>Use custom header link</label>
                                 <frontend_type>select</frontend_type>
                                 <source_model>adminhtml/system_config_source_yesno</source_model>
                                 <sort_order>100</sort_order>
                                 <show_in_default>1</show_in_default>
                                 <show_in_website>1</show_in_website>
                                 <show_in_store>1</show_in_store>
                             </custom_link>
                         </fields>
                     </custom_header>
                 </groups>
             </web>
            ....
    </sections>
</config>

If you add it like this you should find your flag in the Web tab from System->Configuration.
Now you can add this in your template:

<?php if (Mage::getStoreConfigFlag('web/custom_header/custom_link')) : ?>
    Special logo and link here
<?php else : ?>
    Default behavior here
<?php endif;?>

And you can choose from the configuration panel which store has the custom link and logo.