Include Asset in Specific Magento Route
Want to include a JS or CSS file in your Magento theme but only for a specific page? Easy. Just add the following to your layout file:
<route_name>
<reference name="head">
<action method="addCss">
<file>css/style.css</file>
</action>
</reference>
</route_name>
In this example, route_name
would be your underscore separated route which is normally defined in your module e.g. module_controller_action
as in adminhtml_dashboard_index
or catalog_category_view
Written by Dan Hanly
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Layout
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#