J DeBord wrote:
> I've been plugging away and I may have finally got it.
> 
> Take this for example:
> 
> I have a model that returns an array.
> 
> I have a view helper that initializes the model and then calls for the
> model to return the array: class App_View_Helper_Sidebar extends
> Zend_View_Helper_Abstract
> 
> I have a partial that uses the array to render HTML: sidebar.phtml
> 
> In my layout.phtml script I am using the following code to pull it all
> together:
> 
> <?= $this->partial('sidebar.phtml', array('sidebar' =>
> $this->sidebar())); ?>
> 
> Is this the best way to access the model from the view? Does it work
> this way whether accessing the model from your Layout Script or an
> ordinary view script (index.phtml for indexAction, etc.)

Sounding better :)
If I were doing it, I would encapsulate the partial call inside the view
helper:

(In view helper)
return $this->view->partial('sidebar.phtml', array('sidebar' => $sidebar));

Then your call in your view becomes simply:

echo $this->sidebar();

You could also allow a parameter to be passed to the view helper to let
you change the .phtml file, if you needed the ability to render the
sidebar in alternate ways.

> 
> If I am not on the right track, please advise.
> 
> Cheers,
> 
> J

-- 

Brenton Alker
PHP Developer - Brisbane, Australia

http://blog.tekerson.com/

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to