Magento Layout xml in custom module not working

Welcome Magento professionals.

I am writing a custom module for magento and have some problems here. My xml layout is not working. First of all, caching is disabled, compilation is disabled, magento development mode is turned on and registration is turned on. Everything seems to be configured correctly, but I don't even get the exception or the log.

My config.xml modules:

<?xml version="1.0"?> <config> <modules> <Namespace_Module> <version>1.1.0</version> <depends> <Mage_Catalog /> </depends> </Namespace_Module> </modules> <global> <helpers> <module> <class>Namespace_Module_Helper</class> </module> </helpers> <models> ... </models> <blocks> ... </blocks> </global> <frontend> <routers> <module> <use>standard</use> <args> <module>Namespace_Module</module> <frontName>module</frontName> </args> </module> </routers> <layout> <updates> <module> <file> module/module.xml </file> </module> </updates> </layout> </frontend> <admin> <routers> <adminhtml> ... </adminhtml> </routers> </admin> <adminhtml> <layout> <updates> <module> <file>module.xml</file> </module> </updates> </layout> </adminhtml> </config> 

I just set the โ€œNamespaceโ€ and โ€œModuleโ€ as placeholders for my own namespace and user module name.

In the xml layout for the frontend, I simply insert some incorrect configurations to see if it caused an error, but the xml file sees it is not even parsed. For example, I entered <layout> </xxxlayout>

What happened to the configuration?

XML layout file is placed in the base /default/layout/module/module.xml

The admin layout I configured in the same file works fine!

+4
source share
1 answer

It may be a few things (some of them will not be debugged, since you changed your config.xml file before posting here), but one thing that appears right away is

 <file> module/module.xml </file> 

must be specified

 <file>module/module.xml</file> 

For myriad and complex reasons, Magento and PHP parse XML documents with white space meaningful in text nodes. This means that when updating the parsing code of the update code

 #File: app/code/core/Mage/Core/Model/Layout/Update.php public function getFileLayoutUpdatesXml( //... foreach ($updateFiles as $file) { $filename = $design->getLayoutFilename($file, array( '_area' => $area, '_package' => $package, '_theme' => $theme )); if (!is_readable($filename)) { continue; } 

The $filename line that it creates for your code will look like

 string '/path/to/mage/app/design/frontend/base/default/layout/ module/module.xml ' (length=...) 

That is, with a big old piece of space in the middle. This path will not pass the is_readable check, so your layout file will be skipped.

Remove the white space from your node and you will fix one potential problem.

+14
source

Source: https://habr.com/ru/post/1487353/


All Articles