In magento how can I show different-different list.phtml and view.phtml for different -different categories?

I want to show different -different list.phtml and view.phtml for different-different categories .

My code is:

    <reference name="product_list">
    <action method="setTemplate"><name>catalog/product/list_new.phtml</name></action>


With method:

<reference name="">
    <action method="setTemplate"><template>catalog/product/your-view-filename.phtml</template> </action>

product layout is only applied when you visit product from the category page where you have defined it. If you visit product from homepage, for example, it's not applied. What I have done to apply layout to all products that belong to a defined category is to rewrite function getDesignSettings() from Mage_Catalog_Model_Design:

public function getDesignSettings($object)
    if ($object instanceof Mage_Catalog_Model_Product) {
        $customCat = 'XX';
        $productCats = $object->getAvailableInCategories();

        if (in_array($customCat, $productCats))
            $currentCategory = Mage::getModel('catalog/category')->load($customCat);
            $currentCategory = $object->getCategory();
    } else {
        $currentCategory = $object;

    $category = null;
    if ($currentCategory) {
        $category = $currentCategory->getParentDesignCategory($currentCategory);

    if ($object instanceof Mage_Catalog_Model_Product) {
        if ($category && $category->getCustomApplyToProducts()) {
            return $this->_mergeSettings($this->_extractSettings($category), $this->_extractSettings($object));
        } else {
            return $this->_extractSettings($object);
    } else {
         return $this->_extractSettings($category);

Your code will help you use different list.phtml for different categories. To use different view.phtml for different category products, you will have to set different attribute attribute sets and assign different templates for different attributes set. Check this link to how to do it Magento: template based on attribute set


If both the category page and product view page use the same page layout,for eg: category page and product view page uses 1column.phtml page layout, you can use different list.phtml and view.phtml for different categories by following these steps.

  1. In the admin panel goto Catalog > Manage categories
  2. Select the category for which you want to change the list.phtml
  3. Select "Custom Design" tab.
  4. Set "Use parent category settings" to No and "Apply to products" to Yes.
  5. Add this in the "Custom Layout Update" section
  <reference name="product_list">
       <action method="setTemplate"><name>catalog/product/your-list-filename.phtml</name></action>
  <reference name="">
        <action method="setTemplate"><template>catalog/product/your-view-filename.phtml</template></action>

Repeat this for all the categories that you want to change.

Thanks for the post. i just used this one

<reference name="">
    <action method="setTemplate"><template>catalog/product/your-view-filename.phtml</template> </action>

and it's working fine. but if i set one product in multiple categories so it's not handle the layout. it's call same file "your-view-filename.phtml". even i go through from both categories.

Tags: PHP / Magento 1.7

Similar questions

Store view and admin view show different tax for a product
We have one product with 10% vat in our store. In the admin view the tax is calculated and displayed correctly. But the store view shows the product with 24% vat. Would anyone have any ideas on what might cause the problem?
Show only parent categories and sub-categories in left nav
I have currently implemented a code which shows all categories on the left nav instead of that I want current category and current category's all sub categories. Now my category structure is like Now if i am on page Sub1 then I must be able to see all sub categories of sub 1 and also the sub categories of parent1 If I am on sub sub 1 then I must be...
magento 1.9 Which layout XML file specifies which list.phtml file will show a list of subcategories within a category?
I want to specify a different list.phtml for showing subcategories within a category when clicking through categories from the list.phtml used to showcase a list of products. I have one list.phtml that works great for listing subcategories, but then messes up placement of the shopping cart/shopping cart items when showing products. I have another l...
How can I show different category list for different theme?
I have two themes for a single store view...(desktop and iphone) I have created some subcategories under the root category for my store. Let's say those are : Now I want to show only the first 3 categories(1, 2, 3) in the iphone theme.. By default it is showing all of them.. But I don't want to show the last one in the iphone theme only. This is th...
magento 1.9 list.phtml file for category view: view products even if subcategories exist?
At the moment, if a category has products in it, it shows a list of products, which is great. However, if a category has a set of products & subcategories in it, it only shows the subcategories rather than the products. If a category has products and subcategories in it, I want magento to list the products to the user rather than the subcategor...
Toggle price on category/view.phtml and product/view.phtml
I need an option to toggle off/on the price (category/view.phtml and product/view.phtml). Let's say a logged in customer wants to hide the price. So he ticks a checkbox or anything like that which hides prices on the both mentioned view.phtml Is there any way to achieve something like that in magento ? Thanks

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.