1

How can I display category description in footer for all categories & it should not display in homepage

I tried below code.

<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
<div class="category-description std">
    <?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
</div>
<?php endif; ?>
1

You can get description with below code:

<?php
      $layer = Mage::getSingleton('catalog/layer');
      $Category = $layer->getCurrentCategory();
      $Description = $Category ->getDescription();  
?>
|improve this answer|||||
0

Your code will create issue at pages.

In order to current category description.

Solution1: using registry varible

<?php Mage::registry('current_category')){ ?>
<?php $_helper    = $this->helper('catalog/output'); ?>
<?php if($_description=Mage::registry('current_category')->getDescription()): ?>
<div class="category-description std">
    <?php echo $_helper->categoryAttribute(Mage::registry('current_category'), $_description, 'description') ?>
</div>
<?php endif; ?>
<?php  }?>

Solution2: using layout block

<?php 
$CategoryVIewBlock = $this->getLayout()->getBlockSingleton('category.products');
if($CategoryVIewBlock){
$_helper    = $this->helper('catalog/output');
$_category  = $this->getCurrentCategory();

?>

<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
    <div class="category-description std">
        <?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
    </div>
    <?php endif; ?>

<?php } ?>
|improve this answer|||||
  • when i add this code footer didn't diaplay – Payal jhamta Aug 4 '16 at 10:55
0

You should try with Mage::registry,

<?php 
    $currentCategory = Mage::registry('current_category'); 
    if(is_object($currentCategory)):
        $_description = Mage::helper("catalog/output")->categoryAttribute($currentCategory, $currentCategory->getDescription(), 'description');
?>
        <div class="category-description std">
            <?php echo $_description; ?>
        </div>
<?php endif; ?>
|improve this answer|||||
  • Done , but not working – Payal jhamta Aug 4 '16 at 10:26
  • Description should be different for all category but it is displaying same d for all – Payal jhamta Aug 4 '16 at 10:47
  • please clear/disable cache – Anil Suthar Aug 4 '16 at 11:12
  • @payal , in which file you add code ? – Prashant Barot Aug 4 '16 at 12:48
  • @Payaljhamta: updated code (tested and working) – Anil Suthar Aug 4 '16 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.