Skip to content

Instantly share code, notes, and snippets.

@saji89
Last active December 28, 2015 23:29
Show Gist options
  • Save saji89/7578896 to your computer and use it in GitHub Desktop.
Save saji89/7578896 to your computer and use it in GitHub Desktop.
Various ways to render views in Zend
  1. Partials

The Partial view helper is used to render a specified template within its own variable scope. The primary use is for reusable template fragments with which you do not need to worry about variable name clashes. Additionally, they allow you to specify partial view scripts from specific modules.

<?php // partial.phtml ?>
<ul>
    <li>From: <?php echo $this->escape($this->from) ?></li>
    <li>Subject: <?php echo $this->escape($this->subject) ?></li>
</ul>

You would then call it from your view script using the following:

<?php echo $this->partial('partial.phtml', array(
        'from' => 'Team Framework',
        'subject' => 'view partials')); ?>

Which would then render:

<ul>
    <li>From: Team Framework</li>
    <li>Subject: view partials</li>
</ul>

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment