Magento – how use two different logos

magento-1.9theme

I have magento 1.9.1 with the theme "trego". On the home page I have black background, there I want to use a logo with white color, the product pages have white background, there I require a logo with black color.

how can I use different logos for different pages?

Example logo code:

 <a href="http://example.com/" title="Magento Commerce" class="logo"><img src="http://example.com/skin/frontend/default/trego/images/logo.png" alt="Magento Commerce"></a>

Best Answer

You will deal with templates and the local.xml file, which you can create under your theme folder.

I will assume some configurations:

  • That your theme is under app/skin/frontend/rwd/yourtheme/;
  • That you have a local.xml file inside app/skin/frontend/rwd/yourtheme/layout;
  • That exists a header.phtml file in app/skin/frontend/rwd/default/template/page/html/;
  • That you have 2 different .phtml files, each one with the HTML for the corresponding logo: whitelogo.phtml and blacklogo.phtml;

So, first you copy the header.phtml from the above dir into app/skin/frontend/rwd/yourtheme/template/page/html/ and edit it: put <?php echo $this->getChildHtml("logo"); ?> in header where you want the logo to appear.

Copy the whitelogo.phtml and blacklogo.phtml also in this same directory.

Then you edit the local.xml file:

<?xml version="1.0" encoding="utf-8"?>
<layout version="0.1.0">
    <catalog_product_index>
        <reference name="header">
            <block type="core/template" name="logo" template="page/html/blacklogo.phtml"/>
        </reference>
    </catalog_product_index>
    <cms_index_index>
        <reference name="header">
            <block type="core/template" name="logo" template="page/html/whitelogo.phtml"/>
        </reference>
    </cms_index_index>
</layout>

And this should work. In your homepage you will have the white logo and in the product page the other logo.

Related Topic