Thank you very much to everyone who replied to my question, your
advice and suggestions are much appreciated and very helpful.
Jon.
On Dec 3, 2007 3:16 PM, the_woodsman <[EMAIL PROTECTED]> wrote:
>
> Yes, with your tag cloud example, the core functionality for this
> might be best placed in the model.
>
> One reason to go through requestAction to call the model functionality
> is to reuse views.
> For example, perhaps your list of top ten posts in a specified
> category should appear the same way in loads of your pages: in that
> case, it might be handy to have a controller aciton that calls the ´fat
> ´ model, and returns the completed view.
>
> If, however, you need multiple views of the same data, then as you say
> it might be better just to access the fat model in various different
> controllers, and pass this onto different views.
>
>
>
>
>
> On Dec 3, 2:42 pm, SeanW <[EMAIL PROTECTED]> wrote:
> > 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
-~----------~----~----~----~------~----~------~--~---