Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Typically you will assign some bit of data to the view object inside a controller action using something like:</p> <pre><code>$form = My_Form; //assign My_Form to the view object $this-&gt;view-&gt;form = $form; </code></pre> <p>in your view script you would normally access that data using something like:</p> <pre><code>//this bit of code would display your whole form in the view script //along with any layout information contained in your layout file &lt;?php echo $this-&gt;form ?&gt; </code></pre> <p>also items can be assigned to the view object from the bootstrap and these items will be available to the layout or view scripts. Here is an example:</p> <pre><code> protected function _initView() { //Initialize view $view = new Zend_View(); //get doctype from application.ini $view-&gt;doctype(Zend_Registry::get('config')-&gt;resources-&gt;view-&gt;doctype); $view-&gt;headTitle('Our Home'); //get content-type from application.ini $view-&gt;headMeta()-&gt;appendHttpEquiv('Content-Type', Zend_Registry::get('config')-&gt;resources-&gt;view-&gt;contentType); //add css files $view-&gt;headLink()-&gt;setStylesheet('/css/blueprint/screen.css'); $view-&gt;headLink()-&gt;appendStylesheet('/css/blueprint/print.css', 'print'); $view-&gt;headLink()-&gt;appendStylesheet('/css/master.css'); $view-&gt;headLink()-&gt;appendStylesheet('/css/main.css'); $view-&gt;headLink()-&gt;appendStylesheet('/css/nav.css'); //add it to the view renderer $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper( 'ViewRenderer'); $viewRenderer-&gt;setView($view); //Return it, so that it can be stored by the bootstrap return $view; </code></pre> <p>now this data is access inside of a layout.phtml in this manner:</p> <pre><code>&lt;?php echo $this-&gt;doctype() . "\n"; ?&gt; &lt;html&gt; &lt;head&gt; &lt;?php echo $this-&gt;headMeta() . "\n" ?&gt; &lt;?php echo $this-&gt;headLink() . "\n" ?&gt; &lt;!--[if lt IE 8]&gt; &lt;link rel="stylesheet" href="/css/blueprint/ie.css" type="text/css" media="screen, projection" /&gt; &lt;![endif] --&gt; &lt;/head&gt; </code></pre> <p>now for completeness here is the PHP manual version of $this:</p> <blockquote> <p>Within class methods the properties, constants, and methods may be accessed by using the form <em>$this->property</em> (where property is the name of the property) unless the access is to a static property within the context of a static class method, in which case it is accessed using the form <em>self::$property</em>. See Static Keyword for more information. </p> <p><strong>The pseudo-variable</strong> $this is available inside any class method when that method is called from within an object context. $this is a reference to the calling object (usually the object to which the method belongs, but possibly another object, if the method is called statically from the context of a secondary object).</p> </blockquote> <p>This is not a complete explaination but I hope it get's you started.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload