我想在左侧边栏而不是主列中显示类别说明。
我将其添加到我的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>
我创建了这个文件: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>
根本没有结果。我能做错什么?
答案 0 :(得分:9)
以下为我解决了这个问题。
echo Mage::getModel('catalog/layer')->getCurrentCategory()->getDescription();
答案 1 :(得分:4)
您是否曾尝试回复$ _description,因为您在if语句中将其设置为相等?
如果这不起作用,那么只需尝试加载它:
$cat = Mage::getModel('catalog/category')->load($_category->getId());
$description = $cat->getDescription();
答案 2 :(得分:1)
<?php if($category = Mage::registry('current_category')): ?>
<div class="category-description std">
<?php echo $category->getDescription(); ?>
</div>
<?php endif; ?>
答案 3 :(得分:0)
自定义phtml文件中的任意位置:
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$currentCategory = $objectManager->get('Magento\Framework\Registry')->registry('current_category');//get current category information
echo $currentCategory->getDescription();
?>