Note that there are some explanatory texts on larger screens.

plurals
  1. POView Helper, Partial View or Something Else
    text
    copied!<p>I am new to Zend Framework and I have a question about something I am trying to do.</p> <p>The main content of most pages of the application that I am working on will consist of 1 or more div elements that need to be styled the same.</p> <p>Here is an example of the HTML that I want to generate:</p> <pre><code>&lt;div id='admin-locations' class='panel'&gt; &lt;header class="panel-header"&gt; &lt;h2&gt;Locations&lt;/h2&gt; &lt;/header&gt; &lt;div class='panel-content'&gt; &lt;div id='locations-table' class='google-vis-table'&gt;&lt;/div&gt; &lt;form id='locations'&gt; ... &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I know I can easily do this by pushing the form to my view script in my controller then adding this code to my controller.</p> <pre><code>&lt;div id='admin-locations' class='panel'&gt; &lt;header class="panel-header"&gt; &lt;h2&gt;Locations&lt;/h2&gt; &lt;/header&gt; &lt;div class='panel-content'&gt; &lt;div id='locations-table' class="google_vis_table"&gt;&lt;/div&gt; &lt;?php echo $this-&gt;formLocations; ?&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>But that is not DRY.</p> <p>The example I used here has a Google Visualization Table and a Zend Form in it's content. Sometimes the panels will need to contain a form. Sometimes they won't, so I don't think form decorators are the way to go. So basically, the id of the panel, the panel header text and the content of div class='panel-content' need to be dynamic. Everything else will stay the same from panel to panel.</p> <p>What is my best option here?</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