I would really like to use this on a single cms page in magento. For some reason it will not show the content.
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script type="text/javascript">// <![CDATA[
mediaid=191156;subid='';entry=25;provider='0';duration=0;renewal=0;daisyconTelecomFilterView=1;col='1111111';programs='all';header='FFFFFF';background_price='E2F0FB';border='ECECEC';button_text='Bekijken';button_color='FF8300';button_hover='FF9E3D';button_textcolor='FFFFFF';font='Arial';slider='3694C7';minMob='0';maxMob='1000';minMin='100';maxMin='3000';minInt='200';maxInt='6000';minAb='0';maxAb='100';mobiles='all';
// ]]></script>
<script type="text/javascript" src="http://developers.affiliateprogramma.eu/mobielvergelijker/general.js"></script>
<script type="text/javascript" src="http://developers.affiliateprogramma.eu/mobielvergelijker/jquery.nouislider.min.js"></script>
-
do you want to add js file in every cms page?MeenakshiSundaram R– MeenakshiSundaram R2014年03月24日 15:47:06 +00:00Commented Mar 24, 2014 at 15:47
-
No on just one page i need above script, tried allready to fix trough xml layout update -->> No gouser5836– user58362014年03月24日 15:50:28 +00:00Commented Mar 24, 2014 at 15:50
3 Answers 3
Magento has a core/text type block that accepts text input from the layout XML. If you want to add the same files to all the CMS pages add the following to, for example, your local.xml
<cms_page>
<reference name="header">
<block type="core/text"><action method="setText">
<param>
<![CDATA[
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script type="text/javascript">mediaid=191156;subid='';entry=25;provider='0';duration=0;renewal=0;daisyconTelecomFilterView=1;col='1111111';programs='all';header='FFFFFF';background_price='E2F0FB';border='ECECEC';button_text='Bekijken';button_color='FF8300';button_hover='FF9E3D';button_textcolor='FFFFFF';font='Arial';slider='3694C7';minMob='0';maxMob='1000';minMin='100';maxMin='3000';minInt='200';maxInt='6000';minAb='0';maxAb='100';mobiles='all';</script>
<script type="text/javascript" src="http://developers.affiliateprogramma.eu/mobielvergelijker/general.js"></script>
<script type="text/javascript" src="http://developers.affiliateprogramma.eu/mobielvergelijker/jquery.nouislider.min.js"></script>
]]>
</param>
</action>
</block>
</reference>
</cms_page>
Edit :
If you add these code in particular cms page. Then goto cms > pages then click on your page in design tab you can add the above code with out <cms_page> tag in Layout Update XML
-
1that does not work either. :(user5836– user58362014年03月24日 16:13:51 +00:00Commented Mar 24, 2014 at 16:13
-
Did you clear the cache? Are you getting any errors or issues? and did @Meenakshi's method work?Sander Mangel– Sander Mangel2014年03月24日 16:15:19 +00:00Commented Mar 24, 2014 at 16:15
-
cache is disabled, @Meenakshi's method did not work either. there are no errors just a blank page.user5836– user58362014年03月24日 16:20:48 +00:00Commented Mar 24, 2014 at 16:20
-
can you set ini_set('display_errors', 1); in your index page?Sander Mangel– Sander Mangel2014年03月24日 16:22:22 +00:00Commented Mar 24, 2014 at 16:22
-
In the above example there is a
<!CDATA[...]]>tag within a<!CDATA[...]]>tag which is not possible (without any tricks). So probably that's what causing it to fail? You should remove the CDATA inside your Javascript tags. Also, this is not necessary/outdated, but that's a whole different discussion out there...7ochem– 7ochem2014年07月29日 13:05:25 +00:00Commented Jul 29, 2014 at 13:05
Finally got it working. All the javascript files local on server now.
Code below I put in layout update xml field.
<reference name="head">
<action method="addItem">
<type>skin_js</type>
<script>jquery-1.8.3.min.js</script>
</action>
<action method="addItem">
<type>skin_js</type>
<script>general.js</script>
</action>
<action method="addItem">
<type>skin_js</type>
<script>jquery.nouislider.min.js</script>
</action>
<action method="addItem">
<type>skin_css</type>
<script>example.min.css</script>
</action>
<action method="addItem">
<type>skin_css</type>
<script>example.min.css</script>
</action>
<action method="addItem">
<type>skin_css</type>
<script>nouislider.fox.css</script>
</action>
</reference>
The code I use for the content of the page:
<script type="text/javascript">// <![CDATA[
mediaid=171164;subid='smako';entry=25;provider='0';duration=0;renewal=0;daisyconTelecomFilterView=1;col='1111111';programs='all';header='FFFFFF';background_price='E2F0FB';border='ECECEC';button_text='Bekijken';button_color='FF8300';button_hover='FF9E3D';button_textcolor='FFFFFF';font='Arial';slider='3694C7';minMob='0';maxMob='1000';minMin='100';maxMin='3000';minInt='200';maxInt='6000';minAb='0';maxAb='100';mobiles='all';
// ]]></script>
<div id="mobile-comparator-wrapper" class="mobile-comparator-wrapper" style="background-color: #ffffff !important;"> </div>
In admin CMS -> Pages -> Design -> XML Layout Update
<reference name="head">
<action method="addItem">
<type>skin_js</type>
<script>js/filename.js</script>
</action>
</reference>
Source: (Has an error in the script path, which I fixed here.) http://www.mindfreakerstuff.com/2012/10/add-javascript-css-to-home-page-or-specific-cms-page-magento/
Another option is to inline code as such. Note you'll need a name for the block.
<reference name="head">
<block type="core/text" name="anal-expe.js" >
<action method="setText">
<text>
<![CDATA[
<script type="text/javascript">
alert("you rock!");
</script>
]]>
</text>
</action>
</block>
</reference>