Hi, I find that I can add own layout handles with this script:
$this->getLayout()->getUpdate()->addHandle('myhandle');
Then I checked Alan Storm Layout viewers: http://alanstorm.com/2005/projects/MagentoLayoutViewer.tar.gz
?showLayout=handles
Handles 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 layout xml didn't 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 is loaded:
<?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's wrong? Why doesn't work this solution?
If it's not the right way, how can I add custom css and javascript for the page where the widget used?
Update: Here is something which maybe get close to the solution:
If I add this code after I add the new handle to the page:
$this->getLayout()->getUpdate()->fetchPackageLayoutUpdates('myhandle');
$this->getLayout()->generateXml();
After this the "index.php?showLayout=page" call writes handle code in the xml, but the page don't use it.