View helper, partial view or something else

I am new to Zend Framework and I have a question about what I'm trying to do.

The main content of most of the pages of the application I'm working on will consist of 1 or more div elements that must be the same.

Here is an example of the HTML I want to generate:

<div id='admin-locations' class='panel'>
    <header class="panel-header">
        <h2>Locations</h2>
    </header>
    <div class='panel-content'>
        <div id='locations-table' class='google-vis-table'></div>
        <form id='locations'>
            ...
        </form>
    </div>
</div>

I know that I can easily do this by clicking the form on my view script in my controller, and then adding this code to my controller.

<div id='admin-locations' class='panel'>
    <header class="panel-header">
        <h2>Locations</h2>
    </header>
    <div class='panel-content'>
        <div id='locations-table' class="google_vis_table"></div>
        <?php 
            echo $this->formLocations;
        ?>
    </div>
</div>

But this is not DRY.

, , Google Zend . . , , - - . , , div-w970 > "-" . .

?

+3
1

, : http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.partial

, admin-locations.phtml, :

<div id='admin-locations' class='panel'>
    <header class="panel-header">
        <h2>Locations</h2>
    </header>
    <div class='panel-content'>
        <div id='locations-table' class="google_vis_table"></div>
        <?php echo $this->form; ?>
    </div>
</div>

:

...
echo $this->partial('admin-locations.phtml');
echo $this->partial('admin-locations.phtml', array('form' => $this->yourForm);
echo $this->partial('admin-locations.phtml');
...

, .

+4

All Articles