An alternative to excessive use of requestAction is to put as much in the models as you can, and carefully load models in your controllers to pass stuff into views.
For your example, you could: * give all models a random() and recent() method * Create a WithSnippets controller, and subclass this for all controllers that need these snippets * In WithSnippets, pass all these recents and randoms into the view * In the layout (or in helpers), check for the presence of these, and render them if they've been set This might not be the most elegant solution (instead of a WithSnippets controller you could perhaps use Components - it's late here, gimme a break! ) but you get the idea - put your code reuse in the models and things you can share between controllers, so you don't have to use requestAction. This saves you from calling the dispatcher over and over (I think). On Jul 13, 10:35 pm, "Mark (Germany)" <[EMAIL PROTECTED]> wrote: > thats really a good question > i would like to know that mysefl > > i found out though, that requesting might not be the best... > the database querys went up by 30% > especially if you get config details and session infos from the > Database, > they will be requested as often as you use this "requestAction" thing > > makes sense, because it includes these widgets as n external source > reforcing sessionstart etc. > > as soon as i found out, i started to work with controllers, which get > there information > from the models > > dont know if theres a better solution > but i dont wanna have 24 querys where 12 are possibly > > On 13 Jul., 23:01, Steve <[EMAIL PROTECTED]> wrote: > > > Hey, > > > I was wondering what the best approach for creating widgets (type of > > elements) with Cake. What I mean by widgets is basically elements that > > pull data from something that may not relate to the current controller/ > > action the user is in. > > > For example, the default layout may have a sidebar of widgets. So when > > someone is on the home page of the cake app, the sidebar may load the > > following widgets on the left column sidebar as an example: > > > top 5 news stories > > top 10 videos > > random photo > > random post > > > All of those "widgets" (ie: elements) would be pulling data from > > several different models (news from Story, videos from Video, photo > > from Photo, and so on). Is requestAction the best approach to > > achieving something like this? I heard requestAction is heavy on > > resources. Is there another "cake way" of doing this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
