XML : Insert javascript in head from template with magento extension

I am trying to insert some js code in all/some pages of my website through my extension. I want a dynamic version (hosted in a .phtml file) of this:

      <default>          <reference name="head">              <block type="core/text" name="simple_example_javascript_block">                   <action method="setText">                      <text><![CDATA[                      <script type="text/javascript">                          alert("foo");                      </script>                      //]]></text>                  </action>              </block>          </reference>      </default>    

I want the javascript to be hosted in the phtml file

  <script type="text/javascript">    alert("foo");  </script>    

I cannot find any working code on SO or on Google... Thank you

No comments:

Post a Comment