I need to create a block programatically (for various reasons):
$myblock = Mage::app()->getLayout()->createBlock('namespace_module/path', 'my_block', $params);
This works fine, but the controller action is skipped over when doing this. I mean, it is, right? Therefore, my XML layout file is ignored, which contains:
file: app/design/frontend/base/default/layout/namespace_module.xml
<layout>
...
<reference name="head">
<action method="addJs">
<script>namespace_module/script.min.js</script>
</action>
</reference>
...
</layout>
I have tried adding the JS file programmatically as follows, but I get nothing at all:
Mage::app()->getLayout()->getBlock('head')->addJs('namespace_module/script.min.js');
I will also need to reference the CSS file. It's late, so this could be a stupid error. Any guidance/advice welcome. Thank you.