In one project I have used the init of the controller to call the data from the model and then use a partial for setting the menu for the layout. The problem in my case is that for N controllers, I will repeat N times the same code and if I forget to include in one controller I will not have a menu there (among another parts in my layout).
Is that the best way to do it? Is there another way to do (better than this one, of course)?
I do thank for any answer,
2009/12/4 Matthew Weier O'Phinney <matthew@zend.com>
-- Christian Ehmig <ehmig@boerse-go.de> wrote
(on Friday, 04 December 2009, 02:39 AM -0800):
> I've read some discussions about the "evil" ActionStack in this forum andI've spoken and blogged a ton on this in the last year. The answer: this
> specifically here:
> http://www.rmauger.co.uk/2009/03/why-the-zend-framework-actionstack-is-evil/
>
> I commented on that (#19).
>
> Now my question is - how do you setup Zend MVC for complex, highly
> configurable websites or portals (not only simple blog applications with
> basic CRUD operations). In particular, websites that consist of many conrete
> pages that make use of (hopefully) reusable components.
>
> For me the best solution is still:
>
> 1. Writing a Zend_Controller_Plugin that hooks into routeShutdown()
> 2. in routeShutdown() compile the set of actions, their parameters,
> templates and layout targets from a given page configuration (xml file,
> database) and the layout file to be used for that page
> 3. Push these actions to the ActionStack
> 4. done
>
> Any other approaches seem not reusable and "hard-coded" for me. I can give
> further details on my implementation if needed. I am just curious how others
> solve the issue "a page consists of several actions and their respective
> views".
stuff is typically either part of your domain model or part of your view
layer, but has nothing to do with your controllers.
If the reason you're using ActionStack is to re-use business logic...
then that logic should be pushed into your models. If the reason you're
using ActionStack is to re-use view scripts, then simply consume those
view scripts. A judicious use of view placeholders and view helpers can
achieve some tremendous results.
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
--
André de Camargo Fernandes
没有评论:
发表评论