title: How to capture a Zend view output instead of actually outputting it
body: <p>Problem: sometimes in our zend controller we don't want the script to be output directly, but rather want the content of that script. One example: when we need the result html output of a view script be included in another structure like JSON or XML for processing in the client side.</p>
  
  <p>I found the result here at stack overflow, but not so quick since it was in a different context. I have been struggling with this for 2 days now. As it turned out it was very simple:</p>
  
  <pre><code>    // in our controllers' action method
      $this-&gt;_helper-&gt;layout()-&gt;setLayout('empty');    // disable layout
      $this-&gt;_helper-&gt;viewRenderer-&gt;setNoRender(true); // make sure the script is not being rendered
  
      // any of your code here
      $html = $this-&gt;view-&gt;render('projects/climate.phtml');  // return the view script content as a string
      $json = array('html'=&gt;$html, 'initData'=&gt;'my other needed data');
      echo json_encode($json);
  </code></pre>
  
  <p>I hope this was clear and will be useful to somebody.</p>