Benjamin
Benjamin

Reputation: 121

Magento: How can I show the category description in the left sidebar?

I want to display the category description in my left sidebar instead of the main column.

I added this to my catalog.xml:

    <reference name="left">
        <block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/>
    </reference>
            <reference name="left">
        <block type="catalog/navigation" name="catalog.catdes" after="catalog.leftnav" template="catalog/navigation/description.phtml"/>
    </reference>

And I created this file: catalog/navigation/description.phtml

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

There is no result at all. What could I be doing wrong?

Upvotes: 6

Views: 13682

Answers (4)

Homesh Paul
Homesh Paul

Reputation: 151

Anywhere in custom phtml file :

<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$currentCategory = $objectManager->get('Magento\Framework\Registry')->registry('current_category');//get current category information

echo $currentCategory->getDescription();

?>

Upvotes: 0

winterpsv
winterpsv

Reputation: 21

<?php if($category = Mage::registry('current_category')): ?>
<div class="category-description std">
    <?php echo $category->getDescription(); ?>
</div>
<?php endif; ?>

Upvotes: 2

nickspiel
nickspiel

Reputation: 5630

The following solved this issue for me.

echo Mage::getModel('catalog/layer')->getCurrentCategory()->getDescription(); 

Upvotes: 9

Joshua Schuler
Joshua Schuler

Reputation: 461

Have you just tried to echo $_description since you set it equal in the if statement?

If that doesn't work then just try to load it:

$cat = Mage::getModel('catalog/category')->load($_category->getId());
$description = $cat->getDescription();

Upvotes: 4

Related Questions