开发者

Magento separate price.phtml

How can I add a new price template to the category view (template/catalog/product/list.phtml) without changing the price template that is used in (template/catalog/product/view.phtml)? Both files uses the template/catalog/product/price.phtml, but I need a separate price template in template/catalog/product/list.开发者_开发知识库phtml.


It is not a really nice solution, but you could copy price.phtml to your custom theme and then check whether you are on a category page with:

$handles = $this->getLayout()->getUpdate()->getHandles();
if (array_search('catalog_category_view', $handles)) {
    echo 'here you can do other things';
}


Copy app/code/core/Mage/Catalog/Block/Product.php to app/code/local/YourModule/Catalog/Block/Product.php(about the detail of making your own module, you should see other document).

In the copied file, about Line 61, change

public function getPriceHtml($product)
    {
        $this->setTemplate('catalog/product/price.phtml');
        $this->setProduct($product);
        return $this->toHtml();
    }

to

public function getPriceHtml($product)
    {
        $this->setTemplate('catalog/product/your_price.phtml');
        $this->setProduct($product);
        return $this->toHtml();
    }

you can custom the view of price in your_price.phtml.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜