Hi Baz, b,
Thanks for your responses. I like the idea of using Cake's caching
framework - a cache is a more appropriate place to store the generated
data, rather than pushing it back to the database every time.
I'm still slightly confused about the logical place to put the code
which actually generates the HTML. The function itself is about 130
lines long, and does things like generate images for labels which need
to be vertical; it seems like that would be too heavy to go into the
View. But then again, it is strictly creating a visual interpretation
of the data from the model, which is the very definition of what a
view is supposed to do.
I guess at the end of the day, it doesn't really matter. But I would
be intrigued to hear the wiser words of someone more seasoned in the
MVC paradigm.
Thanks again,
Matt.
On Apr 1, 12:19 pm, "b logica" <[EMAIL PROTECTED]> wrote:
> I'll second that. It really seems that Cake could take care of this for you.
>
> Create a view with:
>
> <?= $this->element('your_controller/some_method', array('cache'=>'1 day')) ?>
>
> Put all of your other params in the array as well and they'll be
> available in the view, from where you can pass them through a
> requestAction() to your controller.
>
> In the controller:
>
> function afterSave()
> {
> clearCache('element_cache_your_controller_some_method', 'views', '');
>
> }
>
> Or put the clearCache() wherever it makes the most sense for your situation.
>
> b
>
> On Mon, Mar 31, 2008 at 5:49 PM, Baz <[EMAIL PROTECTED]> wrote:
> > Not sure this will help, but here goes:
>
> > What my Cake experience has shown me is that, there was a lot of stuff that
> > I used to do "manually" that is now made obsolete by CakePHP. I've wasted a
> > lot of trying to to port legacy code into my Cake projects, that I later
> > realized that I didn't need.
>
> > Off the top of my head, CakePHP has some caching features. These may make
> > your database HTML snippet caching more trouble than it's worth. You could
> > cache your "snippet" as an element and include it like that, and you could
> > simply clearCache() for that elemet "when your parameters change".
>
> > Hope this helps....
>
> > On Mon, Mar 31, 2008 at 4:06 PM, Matt <[EMAIL PROTECTED]> wrote:
>
> > > Hi all,
>
> > > My application accepts a fairly large collection of parameters and
> > > uses them to generate an HTML snippet. The snippet is generated
> > > lazily, so that the parameters can change frequently but the HTML is
> > > only generated when it's needed. Once generated, the HTML is cached
> > > (in the database) until the parameters change again.
>
> > > I'm new to MVC, and not sure where thebestplace to put the HTML
> > > generation code is. I would guess that the Model is thebestlogical
> > > place for it, since it will be updating a model reference with the
> > > generated HTML. What makes me wonder though, is that the generation
> > > code actually references other models (because the parameters can be
> > > logically separated).
>
> > > Would the Controller be a better place for this code, or should I
> > > leave it in the Model? If so, how do you access other models from
> > > within a Model class?
>
> > > Many thanks,
> > > Matt.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---