Show content in specific category in Magento

Here’s a little snippet which allows you to enter specific content based on store category. This is handy if you want to show something on a page which belongs to just a specific category only.

<?php if (Mage::registry('current_category') && Mage::registry('current_category')->getId() == 18) { ?>
PUT CONTENT IN HERE FOR CATEGORY WITH ID 18
<?php } ?>

Likewise you can show either content A if on category and if not, show content on all other categories:

<?php if (Mage::registry('current_category') && Mage::registry('current_category')->getId() == 18) { ?>
PUT CONTENT IN HERE FOR CATEGORY WITH ID 18
<?php } else { ?>
PUT CONTENT FOR EVERY OTHER CATEGORY OR PAGE HERE
<?php } ?>

Useful post? Share it

One comment on “Show content in specific category in Magento

Leave a Reply

Your email address will not be published.