Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

Only load stylesheet on Widget pages
Jr. Member
Total Posts:  3
Joined:  2011-02-08

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.

My (hopefully) temporary solution is to load the styles on every page in my layout xml. Is there a better way to do this?

Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top