PiTheNumber
PiTheNumber

Reputation: 23542

Magento: Howto overwrite one template file

There is this template file:

app/design/frontend/base/default/template/catalog/product/view.phtml

I first just changed it but I learned I should have made an overwrite somehow to avoid problems with updates. So I tried to find a tutorial for that but like this question I could not find any that works with Magento 1.7.0.2.

I know I have to create a new template folder and recreate the folder structure catalog/product.

  1. But where do I place this folder?
  2. How do I tell Magento to use it?
  3. Can I somehow skip the xml config stuff?

Upvotes: 2

Views: 3753

Answers (3)

Hardik Shah
Hardik Shah

Reputation: 286

if you want to use the same file the you can copy and paste from default theme to your theme.

But if you want to use your define file then you can use below code in local.xml and put the newly created file in template folder of your or default theme.

<catalog_product_view>
    <reference name="product.info">
        <action method="setTemplate"><template>yourfolder/customfile.phtml</template></action>
    </reference>
<catalog_product_view>

So above file will override default view.phtml

I hope this will help you.

Upvotes: 0

Alex
Alex

Reputation: 34978

  1. Create a folder app/design/frontend/mycompany/default/template
  2. Then you should can configure this so called new package/theme in the backend
    • System -> Configuration -> Design -> Package = mycompany
    • Themes: default (no change should be necessary)
  3. Now your shop uses a completely new theme: yours! But all files that are not defined in your theme will be pulled from base/default (fallback)
  4. To overwrite a template simply copy it to mycompany/default(with same directory structure, so: app/design/frontend/mycompany/default/template/catalog/product/view.phtml) and change whatever you have to change

There should be no need to create any XML files in the layout folder of your theme. In case you need to customize anything with the layout definitions, create a layout/local.xml and make layout updates there. Do not copy for example catalog.xml from the base/default to your theme as this can cause problems with a Magento update.

Upvotes: 3

Anton S
Anton S

Reputation: 12750

You should have defined your own theme and copied the exact path and file to your own theme and change it there.

Upvotes: 0

Related Questions