---------- Forwarded message ---------- From: alessandro cinelli <[EMAIL PROTECTED]> Date: Tue, Mar 18, 2008 at 11:16 AM Subject: Re: [fw-general] Design question about Action View Helper To: SWilk <[EMAIL PROTECTED]>
On Tue, Mar 18, 2008 at 10:58 AM, SWilk <[EMAIL PROTECTED]> wrote: > Hi, > > alessandro cinelli pisze: > > hi, > > as written in the doc: > > > > > > 42.4.1.1 <http://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 have not yet used it, but I understand it this way: > Imagine a forum engine, where there is a simple user profile box by > each post (a box with nickname and a photo, maybe). > You could write an action with gets user info from the model, and > prints it in this simple view. This box Is _reusable_, cause you can > put it by each post, or you could request it with ajax and show dhtml > popup in any place on your app. > > If it was done directly in controller you would have had to write same > code twice - one to print the author profile in the action that shows > an post, and second time to return ajax popup with short profile, and > maybe one more action to print currently logged in user profile in the > right top corner of the page, so that user could see how other users > see him, etc... > Yes , i understand the reusability reason and i agree. But what i mean is that instead of calling $this->action($action,$controller, $module) directly in the view, i think it would be better if you call $this->action($action,$controller, $module) inside the calling action(Main action). The Called action is processed returning the CONTROL to the Main action and passing it the generated values. Then the Main action will call its view rendering also the value passed by the Called action. As Julian Davchev said: "I think ideas was for this to server as kind of a shortcut.", it's a design choice.. What i want to know now is if i change something to implement my own "design", call another action from an action, could it break some Zend Framework features? thanks cirpo
