Last Updated: February 25, 2016
·
460
· danhanly

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