开发者

Magento - determine which xml layout file a page is using?

I tried reading the documentation but I still don’t really understand how magento's xml layout files work.

In the directory app/design/frontend/default/modern/layout, i see a lot of xml files. How do I determine which xml file any given page on the website is using?

For example, if I were on the home page at http://mysite.com, which layout xml file am I using? What if I’m on http://mysite.com/hello-world, which xml file then开发者_开发知识库?


High level version: You're never using just one layout file.

All the XML files are combined in a giant XML file called the Package Layout.

Then, each page request products a number of special string symbols called "handles".

Then, the Package Layout is searched for nodes that match these handles.

The nodes that match are combined into a single XML files called the Page Layout.

That's the layout file any particular request uses.

(shameless, but useful, plugs follow)

I wrote a more in depth article on this, and if you go to the Commerce Bug demo page and look at the Layout tab, you can see an example of the handles any page request produces, as well as see output for the Package and Page Layouts.


As a trivial "start" (but please do read Alan's links), if you are on the page catalog/product/view, the layout handle that is loaded by default is <catalog_product_view>. Overall, though, it is far more complicated than that. Using layout hints you can find out which blocks and templates make up the page, which is often more useful.


every file to layout is loaded here app/code/core/Mage/Core/Model/Layout/Update.php Mage_Core_Model_Layout_Update::fetchFileLayoutUpdates()

constructing xml for page is here: app/code/core/Mage/Core/Model/Layout.php Mage_Core_Model_Layout::generateXml()

People expect them to get an answer here faster than they would get from books and articles.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜