Ok, between this, the wiki and manual things are getting tasty and I
think I'm understanding how to bake better cake... thanks all for the
discussion and feedback.

Previously I was using requestAction to return rendered views from
foreign controllers,  by using it in my elements or directly in the
layout. Apparantly that's what can lead to the overheads associated
with requestAction()

So to avoid rendering the view more than necessary I've altered my
strategy, and the controller methods I'm calling with requestAction
return an array , which I am passing to an element (via renderElement)
which handles the rendering of the view.

>From my understanding of this discussion, the following is an example
of the more efficient way to use requestAction. I'm aiming to include a
list of events on an articles/view page.

It works, but does this look like the right setup for Cake best
practices?

1. In controllers/events_controller.php:
 function eventslist(){
    return $this->Event->findAll() //returns an array of events
  }


2. In views/elements/eventslist.thtml:
 - foreach loop to render the list


3. In controllers/articles_controller.php:
 function view(){

   [...article view stuff...]

     $this->set("eventslist",
$this->requestAction("/events/eventslist"));
 }


4. In views/articles/view.thtml:
 echo $this->renderElement("eventslist",$eventslist);

------------

-ad


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to