你可以这样试试。
$category = Mage::registry('current_category');
<?php if ($category->getFooterText()) : ?>
<?php echo Mage::helper('catalog/output')->categoryAttribute($category, $category->getFooterText(), 'footer_text');?>
<?php endif;?>
但请记住...如果您在 footer.phtml 中添加它,它将无法与块缓存一起使用。页脚被缓存,所以一旦你加载一个页面,上面的代码将不会影响下一页。
[编辑]
如果您想在某些页面上有不同的页脚,您需要修改页脚块的缓存键。这里有一个关于如何做到这一点的解释,但它是针对一个简单的页面而不是一个类别。概念是一样的。
您需要做的只是将getCacheKeyInfo
方法更改为依赖于类别。像这样的东西:
public function getCacheKeyInfo()
{
$info = parent::getCacheKeyInfo();
$category = Mage::registry('current_category');
if ($category) {
$info[] = $category->getId();
}
return $info;
}