I am trying to inject a javascript file in specific page in my admin form. Currently I am overriding a community extension and so far the backend part of the code works as expected. But so far my attempts to load the script were unsuccessful.
An answer in different post states that there is a specific order when creating the appropriate xml node, a quote from there:
To load it on just admin dashboard use the (full 3 element) route with underscores as separators to the page
So, I've dumped the following values in my page:
Mage::app()->getRequest()->getControllerName(); // -> adminhtml_sport
Mage::app()->getRequest()->getActionName(); // -> edit
Mage::app()->getRequest()->getRouteName(); // -> sport
Mage::app()->getRequest()->getModuleName(); // -> sport
What I've added in my xml file:
<adminhtml_sport_sport_edit>
<reference name="head">
<action method="addJs"><script>path/custom/script.js</script></action>
</reference>
</adminhtml_sport_sport_edit>
did not work. As a last note, I would like to ask: Can this be achieved by using the config.xml file in my custom extension and nowhere else?. Thank you for your time.
1 Answer 1
Try with the layout handle sport_adminhtml_sport_edit instead of adminhtml_sport_sport_edit.
The rule for determining the layout handle is {module}_{controller}_{action}.
-
Given that I've placed this code in
app/code/local/myvendor/myext/etc/config.xmlare there any parent nodes forsport_adminhtml_sport_edit? Currently I tried with<adminhtml><layout>and then my node.user33388– user333882015年11月20日 15:21:50 +00:00Commented Nov 20, 2015 at 15:21 -
you should add this inside one of your modules layout file not in
config.xml. something likeapp/design/adminhtml/default/default/layout/{layout_file.xml}Marius– Marius2015年11月20日 15:38:06 +00:00Commented Nov 20, 2015 at 15:38 -
So as it seems, I really can't do it without creating the xml file in
/layout/. I also added the<updates>node and it's childs pointing to my newly created file, and all seems to be working fine. Really appreciated, thank you.user33388– user333882015年11月20日 15:48:12 +00:00Commented Nov 20, 2015 at 15:48
Explore related questions
See similar questions with these tags.