0

I'm new to the magento platform and I am trying my hand at writing my first magento module.

I'm following the guide here: Custom Layouts and Templates with Magento

I've created my module folders and files under app/etc and app/code/local.

I have the following layout code in in my etc/config.xml file:

    <layout>
        <updates>
            <Company_Modulename_layout module="Company_Modulename">
                <file>myfile.xml</file>
            </Company_Modulename_layout>
        </updates>
    </layout>

This looks for myfile.xml in app/design/frontend/default/default, but this confuses me, shouldn't all my custom module files be independent from the default magento folder structure? Is there a way to organise my layout XML files independently from the app/design/frontend/default folders?

Thanks!

3

Actually, this:

<file>myfile.xml</file>

can be in any of the layout folders that are in the inheritance chain for your theme. i.e. app/design/frontend/base/default/layout , which is the "standard" location for module layout updates as the module will be able to find the xml regardless of any theme switching. Also, in the case of using the default rwd theme for example, you could also place the layout file in app/design/frontend/rwd/default/layout.

Standard practice is to name the file along this convention : yourcompany_modulename.xml , which will avoid conflicts with other xml files that happen to be in either directory. If you want to create more separation between your layouts and those from other modules, you could put your layouts in a folder - i.e. app/design/frontend/rwd/default/layout/yourcompany/yourcompany_yourmodule.xml, as long as you add the folder to the path referenced in the xml - something like this:

<layout>
    <updates>
        <Yourcompany_Yourmodule_layout module="Yourcompany_Yourmodule">
            <file>yourcompany/yourcompany_yourmodule.xml</file>
        </Yourcompany_Yourmodule_layout>
    </updates>
</layout>

If you are using your own folder, the company part of the file name may be redundant, but that is a personal naming choice for you to make.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.