Question

When creating a community module i know it is good practice to place template files in the base directory.

But, should they also be under a namespace directory.

For example with a namespace/module of MyCompany/MyModule would the template files be:

app/design/frontend/base/default/template/mycompany/myodule

or just directly under base as in:

app/design/frontend/base/default/template/myodule
Was it helpful?

Solution

There's no hard and fast rule here — I usually go with

app/design/frontend/base/default/template/mycompany_mymodule

There's no Magento system code that will look for a theme folder (template, layout, etc.) based on the module name. Therefore, the only factor driving this module name is that it's unique. Using the full module name (mycompany_mymodule) should do this. You could also use either of the following

template/mycompany

if you wanted for a similar effect.

The problem with

template/mymodule

is there's a much better chance a module name is going to overlap with another module name.

OTHER TIPS

I would say as long as you aren't using a very generic name as your template folder name, just a single folder would be fine in many cases.

That said, putting them under a namespaced folder allows you to further organize your template files, helpful especially if you intend to release several modules and don't want to just scatter your templates all around the top template folder.

There's no architectural reason for you to need to follow one format or another, unlike a module's class files, which do need the my_company namespacing.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top