Zend Framework: Do I need view helpers for this?
Posted: Mon May 26, 2008 11:23 am
I have been starting to learn the Zend Framework these past couple of days, and was wondering if I need to use view helpers for the following:
My website contains lots of blocks which are located in different positions for all pages. Obviously I don't want to code this for all controllers or for each view. I want to, from the view, do something like this:
The problem I have with using view helpers for this is that the helper will need to generate and return HTML, so it would look something like this:
And that just doesn't look or sound right. So, how would I achive this? I have read through the view helpers section on Zend's documentation but am left rather scratching my head.
Thanks
My website contains lots of blocks which are located in different positions for all pages. Obviously I don't want to code this for all controllers or for each view. I want to, from the view, do something like this:
Code: Select all
<div>
<div class="block"><?= $this->block1 ?></div>
<div class="block"><?= $this->block2 ?></div>
....
</div>Code: Select all
<?php
class Zend_View_Helper_MyHelper
{
public function myHelper() {
// Perform some logic here from the Model
return "
<h2>Block title</h2>
<p>....</p>
<p>....</p>
....";
}
}Thanks