I have to use a frontend js file in backend.Currently file is at
/skin/frontend/default/test/js/v1.js
and if I want to use it in backend I have to move it to
/skin/adminhtml/default/default/js/v1.js
but I don't want to duplicate it. So where should I place it. And what should be path in
<action method="addItem">
<type>skin_js</type>
<name>path of js file/v1.js</name>
</action>
-
"and if I want to use it in backend I have to move it to /skin/adminhtml/default/default/js/v1.js" yes that the only correct way to do so.you can not use front js in admintml in layout file.if you want to add ,do add it in your template file by providing front end js pathMinesh Patel– Minesh Patel2015年11月19日 05:26:14 +00:00Commented Nov 19, 2015 at 5:26
3 Answers 3
add your file in js/yourfolder/v1.js you can use same for both admin and frontend
<action method="addJs">
<script>yourfolder/v1.js</script>
</action>
-
He don't want to duplicate the file.MeenakshiSundaram R– MeenakshiSundaram R2015年11月19日 05:24:04 +00:00Commented Nov 19, 2015 at 5:24
-
I don't understand , what are you saying. I said I don't want to make an other copy of file. I want to use original file which is @/skin/frontend/default/test/js/v1.jsAbdul Ghaffar– Abdul Ghaffar2015年11月19日 05:24:37 +00:00Commented Nov 19, 2015 at 5:24
-
@AbdulGhaffar added commentMinesh Patel– Minesh Patel2015年11月19日 05:26:59 +00:00Commented Nov 19, 2015 at 5:26
-
@AbdulGhaffar updated the answer..Qaisar Satti– Qaisar Satti2015年11月19日 05:27:24 +00:00Commented Nov 19, 2015 at 5:27
-
@QaisarSatti " js/yourfolder/v1.js" you mean js in main projectAbdul Ghaffar– Abdul Ghaffar2015年11月19日 05:30:06 +00:00Commented Nov 19, 2015 at 5:30
That's easy. Just follow below steps:
- Move v1.js in js directory as /js/v1.js
- Access this file from both frontend & backend using below command in your layout xml file
>
<action method="addItem"><type>js</type><name>v1.js</name></action>
Please try same as bellow code in your frontend & backend layout file
frontend layout file
<default>
<reference name="head">
<action method="addJs"><script>test/test.js</script></action>
</reference>
</default>
backend layout file
<default>
<reference name="head">
<action method="addJs"><script>test/test.js</script></action>
</reference>
</default>
-
How is it possible, you are trying to access same form two different places with same path, with out placing it on specific pointAbdul Ghaffar– Abdul Ghaffar2015年11月19日 05:47:01 +00:00Commented Nov 19, 2015 at 5:47
-
This will add js from js folder only and not from skin_jsMinesh Patel– Minesh Patel2015年11月19日 05:48:14 +00:00Commented Nov 19, 2015 at 5:48
-
have you used one form in frontend & second in backend right?Abdul– Abdul2015年11月19日 05:48:45 +00:00Commented Nov 19, 2015 at 5:48
-
in magento js/prototype/prototype.js is use forntend and also backendAbdul– Abdul2015年11月19日 05:52:55 +00:00Commented Nov 19, 2015 at 5:52
-
you are follow same as prototype.js (location at forntend app\design\frontend\base\default\layout\page.xml and backend app\design\adminhtml\default\default\layout\main.xmlAbdul– Abdul2015年11月19日 05:56:18 +00:00Commented Nov 19, 2015 at 5:56
Explore related questions
See similar questions with these tags.