Reputation: 121
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
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
Reputation: 21
<?php if($category = Mage::registry('current_category')): ?>
<div class="category-description std">
<?php echo $category->getDescription(); ?>
</div>
<?php endif; ?>
Upvotes: 2
Reputation: 5630
The following solved this issue for me.
echo Mage::getModel('catalog/layer')->getCurrentCategory()->getDescription();
Upvotes: 9
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