Parvez
Parvez

Reputation: 89

How to place custom template (phtml) file in local module direcotry instead of default template directory

I am creating a new module for my Magento project where I have a few template files which get appended to >catalog_product_view catalog_category_default checkout_cart_index and few other pages. Currently, I have placed my module configuration file in >design/fontend/base/default/layout/modulename_subfolder.xml and template file is placed at >design/frontend/base/default/template/modulename/subfolder/my_product_view.phtml

I want to move this XML and phtml files to local/modulename/subfolder

I have tried creating the same folder structure in my module folder but it didn't work

design/fontend/base/default/layout/modulename_subfolder.xml


<layout version="0.1.0">
  <catalog_product_view>
    <reference name="content">
      <block type="core/template" name="modulename_subfolder_product_view_block" template="modulename/subfolder/my_catalog_product_view.phtml" />
    </reference>
  </catalog_product_view>
</layout>

Upvotes: 0

Views: 210

Answers (2)

Krzychu
Krzychu

Reputation: 1

You must do symlink in htdocs/app/design/frontend/base/default/template/yourcompany/module that points to your module same dir.

Upvotes: 0

Marco Acquati
Marco Acquati

Reputation: 81

You can do that, but it is not correct. If you have hard times to find files in your magento structure you need to practice more, and you will see that it is not that hard as it seems.

Whatever, put your files in your Magento's module (in any subfolder), then go to the correct place where they should be (like: frontend/design/.../file.phtml) and create a file that includes your module's files path.

For template files, just open the php tags and include it; like this reference shows https://www.php.net/manual/en/function.include.php

for xml is almost the same; follow this answer for XML Can we import XML file into another XML file?.

I suggest to not do that, but instead put your files where they belong.

Upvotes: 0

Related Questions