On Dec 2, 7:56 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
> Using elements is what you want. Inside the elements you can use
> requestAction to get at any data you wish to use. You can return an
> array of data directly, or render a view. See tutorial here for an
> example (and also how to cache the result)

That tutorial certainly explains requestAction and how cool it is, but
I'm left thinking "what happened to the skinny controller, fat model"
concept?  Why am I going to wind my way (again) through the Cake
framework only to get at a piece of data that the model should know
about anyway?

For example, tag cloud.  We have a tag model, presumably linked to
posts or something.  Within the tag model I'd have a function,
tagCloud, that would return the tag cloud in an array, something like

$ret[0]["tag"] = "cake";
$ret[0]["count"] = "5";
$ret[1]["tag"] = "php";
$ret[1]["count"] = "6";

In the controller generating the post, we'd add "Tags" to the $uses
array, and in the action do a

$this->set("tagcloud", $this->Tag->tagCloud());

The tag cloud HTML would be encapsulated in an element so that anyone
could use it from the view, $this->renderElement("tagcloud",
array("data" => $tagcloud))

None of this precludes using requestAction...  In fact the reason I
arrived at this conclusion is by starting off there, realizing the job
of collecting the tag cloud data belongs in the model, realized we
need an element anyway, so why bother using requestAction when I can
just set() it in the controller and still be blissfully unaware about
how the data is constructed?

BTW this extends to the other cases the OP mentioned, ie $this->Books-
>getReadingList(5), etc.

The post that opened my eyes to the fat model concept:

http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model

It's written for Ruby on Rails, but it's easy enough to translate to
PHP.

Sean
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to