Re: Using the PagesController

2008-12-11 Thread brian

This is what elements are for. There's no need to modify PagesController.

On Thu, Dec 11, 2008 at 11:58 AM, Rob Wilkerson [EMAIL PROTECTED] wrote:

 This is a pretty straightforward question, I think, but I can't find
 much information about using the page controller effectively, so I
 decided to just ask.  My homepage is using the typical page controller
 (moved to app/controllers) and home.ctp view.  However, now I need to
 make some dynamic information available. I need to load a model, but
 only for the homepage.

 Given that there's a single page controller (and I don't particularly
 want a separate controller for each page), is there any way to tell
 the controller to load the model I need, but only when the homepage is
 requested? If so, how do I need to modify the PagesController to make
 that happen?

 Thanks.
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP 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?hl=en
-~--~~~~--~~--~--~---



Re: Using the PagesController

2008-12-11 Thread Rob Wilkerson

On Thu, Dec 11, 2008 at 12:04 PM, brian [EMAIL PROTECTED] wrote:

 This is what elements are for. There's no need to modify PagesController.

This is true, so let me ask a couple of follow up questions around
best practices, etc.

First, in this case, I'd only need this element once. Is an element
still the best option?
Second, how should I make a model available to the element so that I
can find() the records I need to display?

Thanks for your help.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP 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?hl=en
-~--~~~~--~~--~--~---



Re: Using the PagesController

2008-12-11 Thread Sam Sherlock
I would say that element would be best but because you need to model-find
you need to use something like requestAction
or
http://mark-story.com/posts/view/reducing-requestaction-use-in-your-cakephp-sites-with-fat-models

as your doing a little and only want template echo'd in view and calls to
helpers and elements



2008/12/11 Rob Wilkerson [EMAIL PROTECTED]


 On Thu, Dec 11, 2008 at 12:04 PM, brian [EMAIL PROTECTED] wrote:
 
  This is what elements are for. There's no need to modify PagesController.

 This is true, so let me ask a couple of follow up questions around
 best practices, etc.

 First, in this case, I'd only need this element once. Is an element
 still the best option?
 Second, how should I make a model available to the element so that I
 can find() the records I need to display?

 Thanks for your help.

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP 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?hl=en
-~--~~~~--~~--~--~---



Re: Using the PagesController

2008-12-11 Thread Rob Wilkerson

On Thu, Dec 11, 2008 at 12:18 PM, Sam Sherlock sam.sherl...@gmail.com wrote:
 I would say that element would be best but because you need to model-find
 you need to use something like requestAction
 or
 http://mark-story.com/posts/view/reducing-requestaction-use-in-your-cakephp-sites-with-fat-models

 as your doing a little and only want template echo'd in view and calls to
 helpers and elements

Haven't I been reading that requestAction() is generally considered a
bad thing these days? I think I read the word harmful somewhere.
Maybe on the Debuggable blog? Is that the case or is this the proper
use of that technique?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using the PagesController

2008-12-11 Thread brian

On Thu, Dec 11, 2008 at 6:26 PM, Rob Wilkerson r...@robwilkerson.org wrote:

 On Thu, Dec 11, 2008 at 12:18 PM, Sam Sherlock sam.sherl...@gmail.com wrote:
 I would say that element would be best but because you need to model-find
 you need to use something like requestAction
 or
 http://mark-story.com/posts/view/reducing-requestaction-use-in-your-cakephp-sites-with-fat-models

 as your doing a little and only want template echo'd in view and calls to
 helpers and elements

 Haven't I been reading that requestAction() is generally considered a
 bad thing these days? I think I read the word harmful somewhere.
 Maybe on the Debuggable blog? Is that the case or is this the proper
 use of that technique?

The link points to some advice for *reducing* the use of
requestAction(). In any case, I think it's really a relative thing.
One has to weigh the advantages and disadvantages for using it in each
situation. I certainly wouldn't use it in several elements on a page
but I might for just one. Especially as the output can be cached.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using the PagesController

2008-12-11 Thread Rob Wilkerson

On Thu, Dec 11, 2008 at 6:35 PM, brian bally.z...@gmail.com wrote:

 The link points to some advice for *reducing* the use of
 requestAction(). In any case, I think it's really a relative thing.
 One has to weigh the advantages and disadvantages for using it in each
 situation. I certainly wouldn't use it in several elements on a page
 but I might for just one. Especially as the output can be cached.

Yeah, sorry. I read the article, but was following up on a related
thought because the article, if I read it correctly, assumes the
presence of a controller to do this:

$comments = $this-Post-Comment-recent();

In my case, the PagesController is being used and it seems like I
should avoid modifying that particular controller (though I have no
real basis for thinking that). Regardless, I'd rather not drop the
code in the controller to be executed for _all_ pages I may use since
this is only needed for one particular controller.

Thoughts?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using the PagesController

2008-12-11 Thread Sam Sherlock
modifying files in your app directory is ok - is more code to supervise its
how I would go about your objective (from what I understand of it) - mark's
approach involves editing more files to set up - but works a treat.

requestAction can be ok - but can be problematic also can really slow down
your app

KISS - keep everything simple as possible though


2008/12/11 Rob Wilkerson r...@robwilkerson.org


 On Thu, Dec 11, 2008 at 6:35 PM, brian bally.z...@gmail.com wrote:
 
  The link points to some advice for *reducing* the use of
  requestAction(). In any case, I think it's really a relative thing.
  One has to weigh the advantages and disadvantages for using it in each
  situation. I certainly wouldn't use it in several elements on a page
  but I might for just one. Especially as the output can be cached.

 Yeah, sorry. I read the article, but was following up on a related
 thought because the article, if I read it correctly, assumes the
 presence of a controller to do this:

 $comments = $this-Post-Comment-recent();

 In my case, the PagesController is being used and it seems like I
 should avoid modifying that particular controller (though I have no
 real basis for thinking that). Regardless, I'd rather not drop the
 code in the controller to be executed for _all_ pages I may use since
 this is only needed for one particular controller.

 Thoughts?

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using the PagesController

2008-12-11 Thread Brett Wilton

If your model data isn't changing much using an cached element should
be quick.  You can set the cache to renew each hours, days, weeks, or
longer.  You could also clear the element cache when you save the
model.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---