Total Posts: 3
How can I dynamically load stylesheets into the “head” section in Magento only on pages that include a custom Widget?
For my scripts I’m doing this:
This is the current content of _prepareLayout() in my Widget block class. I tried using the same method for styles, swapping before_body_end for head, and that worked great for placing Widget Instances or manually placing the block in my layout xml, however when inserting a widget inline in a Page’s content the head section seems to be rendered prior to the Widget, and therefore my styles template can’t be inserted into the head block.
$block = $this->getLayout()
My (hopefully) temporary solution is to load the styles on every page in my layout xml. Is there a better way to do this?