1

I want to add a banner directly underneath the nav bar but I only want it to display on category pages, I have added a static block in cms and I have had it display on all pages via using the header.phtml file (and just putting it at the end of the file) but I only want to to display on category pages so I can't use the header.phtml file as that is called on all pages and there is no category template that I can call it in that will display it where I want it. I have tried adding:

<block type="cms/block" name="top_images">
    <action method="setBlockId"><block_id>top_images</block_id></action> </block>

into catalog.xml (in the layout folder of my theme) but that doesn't seem to show up.

Any suggestions?

1 Answer 1

0

you can use this add this your header it will show block only on category pages

<?php  $currentUrl = Mage::getUrl('*/*/*', array('_current' => true));
if (strpos($currentUrl,'catalog/category') == true) { echo $this->getLayout()->createBlock('cms/block')->setBlockId('top_images')->toHtml(); } ?>
2
  • 1
    Thank you very much! Just worth mentioning that I originally got a PHP error with this code but ofc you just missed a semi-colon, always that way!
    – Eujinks
    Commented Jan 15, 2016 at 11:13
  • 1
    <?php $currentUrl = Mage::getUrl('/*/', array('_current' => true)); if (strpos($currentUrl,'catalog/category') == true) { echo $this->getLayout()->createBlock('cms/block')->setBlockId('top_images')->toHtml(); } ?>
    – Eujinks
    Commented Jan 15, 2016 at 11:13

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.