Created
March 2, 2016 11:31
-
-
Save proxium/eb4ecfbc483c6f4fa72c to your computer and use it in GitHub Desktop.
Magento: add layout xml via event to add the layout file direct before local.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
config.xml | |
<?xml version="1.0"?> | |
<config> | |
<modules> | |
<Loewenstark_Layout> | |
<version>1.0.0.0</version> | |
</Loewenstark_Layout> | |
</modules> | |
<global> | |
<models> | |
<loewenstark_layout> | |
<class>Loewenstark_Layout_Model</class> | |
</loewenstark_layout> | |
</models> | |
<events> | |
<core_layout_update_updates_get_after> | |
<observers> | |
<loewenstark_layout_add_layout_xml> | |
<type>singleton</type> | |
<class>loewenstark_layout/observer</class> | |
<method>addLayoutXml</method> | |
</loewenstark_layout_add_layout_xml> | |
</observers> | |
</core_layout_update_updates_get_after> | |
</events> | |
</global> | |
</config> | |
Observer.php | |
*/ | |
<?php | |
class Loewenstark_Layout_Model_Observer | |
{ | |
// set loewenstark_layout.xml before local.xml | |
public function addLayoutXml($event) | |
{ | |
$xml = $event->getUpdates() | |
->addChild('loewenstark_layout'); | |
/* @var $xml SimpleXMLElement */ | |
$xml->addAttribute('module', 'Loewenstark_Layout'); | |
$xml->addChild('file', 'loewenstark_layout.xml'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment