2010年9月9日星期四

[fw-mvc] Re: controller/view

weierophinney wrote:
>
> You could also pass them to a partial to render:
>
> <?php echo $this->partial('members', $house->members) ?>
>
> and put the logic in your partial.
>

In general I favor partials (depending on the situation), simply because
that logic is now re-usable. If you need to have that same list displayed
on multiple pages you can simply call the partial. I also like to create
view helpers to pass entities to so that they are consistently displayed
across the site.

<?php foreach($this->houses as $house) :
<tr>
<td><?php echo $this->printTypes($types);?></td>
<td><?php echo $this->escape($house->ownership);?></td>
<td><?php echo $this->escape($house->income);?></td>
<td><?php echo $this->printMembers($members);?></td>
</tr>
<?php endforeach ?>

That way, if you want to adjust how you display the types or members, you
can change it in one place and your entire site remains consistent.
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/controller-view-tp2531737p2533193.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: