I find that I can add my own layout layouts using this script:
$this->getLayout()->getUpdate()->addHandle('myhandle');
Then I checked out the Alan Storm Layout viewers: http://alanstorm.com/2005/projects/MagentoLayoutViewer.tar.gz
? ShowLayout = pens
Pens for this request
- Default
- cms_page
- STORE_default
- THEME_frontend_default_default
- cms_index_index
- page_two_columns_left
- customer_logged_out
- myhandle
There was my handle, but my custom xml layout was not used.
Here is my xml:
<?xml version="1.0"?> <layout version="0.1.0"> <myhandle> <reference name="head"> <action method="addJs"><script>test/your.js</script></action> </reference> </myhandle> </layout>
This works fine, so the xml file loads:
<?xml version="1.0"?> <layout version="0.1.0"> <default> <reference name="head"> <action method="addJs"><script>test/your.js</script></action> </reference> </default> </layout>
What happened? Why is this not working?
If this is not the case, how to add custom CSS and javascript for the page where the widget was used?
Update: Here's what might come close to a solution:
If I add this code after adding a new handle to the page:
$this->getLayout()->getUpdate()->fetchPackageLayoutUpdates('myhandle'); $this->getLayout()->generateXml();
After that, calling "index.php? ShowLayout = page" writes the processing code in xml, but the page does not use it.
source share