【发布时间】:2013-08-05 08:32:13
【问题描述】:
我使用了以下代码,但不适用于这种情况:
$_category_detail=Mage::registry('current_category');
echo $_category_detail->getName();
得到致命错误:在 /app/design/frontend/base/default/template/catalog/product/view.phtml 中的非对象上调用成员函数 getName() p>
我们制作了一些过滤器并在 head.phtml 中使用下面提到的代码:
$is_product = Mage::registry('product');
if($is_product){
if(is_object(Mage::registry('current_category'))){
$category_name = Mage::registry('current_category')->getName();
}
else{ $category_name = ""; }
}
但这只有在您从一个类别转到一个产品时才有效。如果您直接访问产品页面,则不会显示任何内容
【问题讨论】:
标签: php magento magento-1.5