1
votes

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.

2
Here's a similar question asked and answered with a nice xml solution that could be helpful: stackoverflow.com/questions/2911615/… - ccondrup

2 Answers

2
votes

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';
}
1
votes

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.