Here is what I think about Magento (plz correct me if I am wrong )
1)Each module has its own layout.xml stored in /interface/theme/layouts/ folder.
2)Magento loads all these layouts for current theme and creates a big xml file.
Now what I am confused at .
a)If magento loads /default/default/ (interface & theme) then why all the templates & layouts are inside base/default/ ??
b)what if I create my module name “page” inside my namespace “Jason” i.e Jason_Page , now what will happen to blocks in layout files which are named
c)Since all the layouts are loaded and merged into one big xml file , then what happen to all those reference blocks which have same name attribute and are inside “Default” handle tag ?
e.g
d)what is Local.xml layout for and its use ??
e)wats the relation ship between a module name foo , and its layout name foo.xml ?
What will happen to layout.xml if two modules with same name exist in diff namespace ?
Thanks in advance .
1) Each module can choose to define layout files that go into the /interface/theme/layouts/ folder. You can accomplish this by specifying the layouts in your module’s config.xml file like this:
2) Yes.
a) Magento’s interface is built using descendency. Templates and layouts are first taken from your chosen interface and theme, and if not found there, will be taken from base. This allows you to define only those things that change from the base when creating a new them.
b) If you create a new module with blocks, you will specify the classpath for those blocks in your config.xml:
This will define the tag
jason_pageto refer to your blocks. Then, when defining a layout, you will reference your blocks as:And your blocks will be named as:
Jason_Page_Block_Blocknamein/app/code/local/Jason/Page/Block/Blockname.phpc) Each time you use a
<reference>tag and add some child blocks, they are added to the large tree as you say. Make sure to use differentname/astags for the blocks, and you’ll be fine. If the name is identical, you will probably cause errors.d) local.xml (in app/etc) defines some configuration parameters for your site, such as database connection information and encryption keys. it doesn’t have to do with layouts.
d part 2) Since you define your layout files, including their names, it’s up to you to not cause collisions. Choosing a module name more unique than Page would go far here. If you do have a module with the same name as a default module (e.g. Page), prefix the file with your namespace when declaring it in your config.xml file.
Hope that helps!
Thanks,
Joe