我正在尝试实例化review helper类,但失败了。我需要访问(app/code/code/Mage/Review/Block/Product/View.php).类Mage_Review_Block_Product_View的getReviewsSummaryHtml()
我试过了:
Mage::helper('review/product')->getReviewsSummaryHtml($_product, false, true);但我收到致命错误:找不到类'Mage_Review_Helper_Product‘。
我做错了什么?
(附注:我不能使用$this->getReviewsSummaryHtml,因为$this超出了作用域。)
谢谢
发布于 2011-11-29 23:20:37
在Mage_Review_Block_Product_View中定义了getReviewsSummaryHtml()方法。您可以使用Mage::app()->getLayout()->createBlock('review/product_view',$product);在任何地方实例化它。但是,为了使其正常工作,还需要有一个名为product_review_list.count的块实例,该实例通常在review.xml中定义,类型为core/template,并使用review/product/view/count.phtml模板。
发布于 2011-11-29 23:20:09
您只需执行以下操作:
Mage::helper('review')为了获得名为Data.php的帮助器类
函数getReviewsSummaryHtml()驻留在一个块中,您应该只能从模板中调用该函数(理想情况下)。
如果您已将该函数移动到helper,则可以像这样调用它:
Mage::helper('review')->getReviewsSummaryHtml();并且您应该在本地进行所有这些更改。
https://stackoverflow.com/questions/8312802
复制相似问题