2

Can you put module layout files within the Module's code directory in Magento 1.13? This is as opposed to putting them in /app/design/...

4

In short, no, you can't. But it is the way Magento 2 is heading...everything in the single module directory.

If you are creating a distributable module which has it's own layout file, put it in /app/design/<area>/base/default/layout/ and it will take effect regardless of the theme that is used. Just please don't do this if it's custom development work for a one-off project.

  • 1
    "Just please don't do this if it's custom development work for a one-off project." Why not? It's the purpose of the base/default theme to be the fail safe for theme assets. – benmarks Jun 16 '13 at 12:37
  • 1
    If the changes are specific to the project and non-distributable, then these files belong in the custom theme directory and not base/default IMO. Having them in base/default does make sense if the module is portable and does not exist solely for the purpose of implementing design requirements of the site. It's also the wrong place to put them if the project is a multi-site project where they are not needed on all the individual sites. Should have clarified what I meant, and I absolutely agree that it's where they belong for redistributed modules. :) – davidalger Jun 16 '13 at 12:44
  • 1
    Actually we're still in disagreement, though it's somewhat academic. Benefits of using base/default: 1) no concern about theme settings 2) consistency for all assets across all implementations, i.e. any dev knows where to start for any theme asset. I'm sure there are others. That said, enterprise/default muddles this approach a bit. – benmarks Jun 16 '13 at 13:03
  • 1
    "consistency for all assets across all implementations" Are you also suggesting that the custom theme be built directly in base/default then? – davidalger Jun 16 '13 at 13:09
  • 1
    Not at all, just that any theme asset should begin in base/default. Customizations of existing assets should not (bc of upgrade path). The notable exception is local.xml layout file. Also, I can image that for a single-theme Magento instance one may prefer to manually aggregate all theme files in one theme. I prefer not to do this because I find it a nightmare to deal with during upgrades. – benmarks Jun 16 '13 at 13:28
3

No, not natively, but it is certainly possible - and really quite easy at that.

There's another answer here that outlines how to add another directory to be read when parsing layout XML files (and in order of preference).

You could make couple of adjustments to make it also read from your own module directory.

  • What adjustments? – user2045 Jun 6 '14 at 20:07
2

No you cannot. You will be able to do it in Magento 2.0.

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.