views:

42

answers:

1

I'm using Zend_View_Helper_HeadScript to add JavaScript code inside the <head> tag.

$view->headScript()->appendScript($javascript);
$view->headScript()->appendScript($javascript2);

This works fine, except that my code is full of <script> tags (one for each appendScript call). How to add $javascript2 to the same <script> tag? I just want to have one <script> tag inside the <head>.

What's the difference between headScript and inlineScript?

+2  A: 

Please try

$view->headScript()->appendScript($js1)->appendScript($js2);
echo $view->headScript();

InlineScript is used if you have to add script inside your <body> Tag.

ArneRie
Thanks, but I use `appendScript()` in different places (custom view helpers).
Adrian
@Adrian just out of curiosity why is it that you need to have only one script tag. As far as I know its of no impact other then the code looking a little bit uglier.
Iznogood
Better readability, easier processing, (a bit) faster execution.
Adrian