I encountered the situation this week where there were a few different products that needed to use a slightly modified view.phtml and media.phtml templates. Fortunately, that’s incredibly easy to do.
First, create your new template files. I copied the originals, and created view-rugs.phtml, and media-rugs.phtml in the same directories as the originals. Once that is complete, edit a product, and go to the “Design” tab. In the “Custom Layout Update” text area, you can put the following, which will redefine which templates it uses for that product (I will explain why it works below):
<reference name="product.info"> <action method="setTemplate"> <template>catalog/product/view-rugs.phtml</template></action> </reference> <reference name="product.info.media"> <action method="setTemplate"> <template>catalog/product/view/media-rugs.phtml</template></action> </reference>
How does this work? If you were to open up the catalog.xml layout xml file, and scroll down to the “catalog_product_view” section, you’ll see that there are a bunch of templates being loaded up for the product view. Any of these blocks that load up a template can be changed. They all have a name=”something”. If you reference that name (like I did above), you can call the setTemplate action on it to change it to whatever you want it to be.