-- alessandro cinelli <[EMAIL PROTECTED]> wrote
(on Tuesday, 18 March 2008, 10:11 AM +0100):
> 42.4.1.1. Action View Helper
> 
> " The Action view helper enables view scripts to dispatch a given controller
> action; the result of the response object following the dispatch is then
> returned. These can be used when a particular action could generate re-usable
> content or "widget-ized" content."
> 
> i'm curious to know why i have to do this in the View and not in the
> Controller.
> Would'nt be more logic to call the other action  within the "caller" action 
> and
> then assign the values to the View?
> is there  a particular "design" reason or am i missing something?
> 
> I don't want to start a flame, i'm just interested do understand the Zend
> Framework design.

You may want to take a look at Paddy's series on complex views:

 * 
http://blog.astrumfutura.com/archives/281-Complex-Web-Pages-with-the-Zend-Framework.html
 * 
http://blog.astrumfutura.com/archives/282-Complex-Views-with-the-Zend-Framework-Part-2-View-Helper-Pattern.html
 * 
http://blog.astrumfutura.com/archives/283-Complex-Views-with-the-Zend-Framework-Part-3-Composite-View-Pattern.html
 * 
http://blog.astrumfutura.com/archives/285-Complex-Views-with-the-Zend-Framework-Part-4-The-View-Factory.html
 * 
http://blog.astrumfutura.com/archives/288-Complex-Views-with-the-Zend-Framework-Part-5-The-Two-Step-View-Pattern.html
 * 
http://blog.astrumfutura.com/archives/291-Complex-Views-with-the-Zend-Framework-Part-6-Setting-The-Terminology.html

Basically, the action() helper is for those situations where a helper
that queries a model is insufficient -- for instance, if you need to
verify that the current user has rights to a given resource, or if you
want to embed the content of another action within the current view. The
idea is that you can then build up pieces of content from other actions.

Purists will argue that this should be done in the controller -- for
instance, by using the ActionStack helper/plugin to build up content
segments that are then injected into the layout. 

However, different developers have different needs and approaches, and
we've simply added the flexibility to do it more than one way. If you
don't like the action() helper or the fact that it exists, simply don't
use it.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to