title: ZendFramework - How to add ->HeadScript() from Controllers?
body: <p>I have a case where i need to add the Javascript from controller to the Layout where it has already HeadScript();</p>
  
  <p>How to do that from controller?</p>
  
  <p>e.g: <code>$this-&gt;view-&gt;HeadScript()-&gt;appendScript();</code></p>
  
  <p>This is controller: Both does not apply.</p>
  
  <pre><code>class RouterController extends Zend_Controller_Action
  {
    public function init()
    {
      $this-&gt;view-&gt;HeadScript()-&gt;appendFile('/js/test.js')-&gt;setIndent(8);
      $this-&gt;view-&gt;HeadScript( Zend_View_Helper_HeadScript::FILE, '/js/test.js' );
    }
  }
  </code></pre>
  
  <p>This is the view file: index.phtml</p>
  
  <pre><code>&lt;?//$this-&gt;HeadScript()-&gt;appendFile('/js/test.js')-&gt;setIndent(8);?&gt;
  </code></pre>
  
  <p>If i uncomment in view it works but not in Controller. I want to apply this from controller how now?</p>