0

I'd like to add the category title to the product view page in Magento. I have the following code that currently pulls the category banner to the product view page:

<?php
    if(Mage::registry('current_category')):
        $_category=Mage::registry('current_category');
        $_helper    = Mage::helper('catalog/output');
        $_imgHtml   = '';
        if ($_imgUrl = $_category->getImageUrl()) {
            $_imgHtml = '<p class="category-image"><img src="'.$_imgUrl.'"     alt="'.$this->escapeHtml($_category->getName()).'" title="'.$this->escapeHtml($_category->getName()).'" /></p>';
            $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
        }
?>
    <?php if($_imgUrl): ?>
        <?php echo $_imgHtml ?>
    <?php endif; ?>

<?php endif; ?>

Can I adapt the above so the category title is also displayed?

3
  • you want to disable category title in listing page right
    – Magento 2
    Commented Oct 5, 2015 at 20:13
  • No, I'd like to add the category title to the product view page. Commented Oct 5, 2015 at 20:15
  • can you plz show me that page
    – Magento 2
    Commented Oct 5, 2015 at 20:17

1 Answer 1

5

Try:

echo $_category->getName();

That should do it!

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.