Hi all thanks for the help.. I a totally beginner in PHP, so bear
with me.
I have thought a little and put this in my controller function (try to
have as little logic in my view as possible)
The problem is that it returns blank.. totally blank page, no data at
all. I've turned on debbuging with Configure::write('debug', 3) in
core.php.
And it takes some seconds to finish. Is it a problem in my php code?
I don't know if i'm going to use $story['story']['id'] or just
$story['id'] to return the id. Both times it returns a blank page.
$comments = array();
foreach ($this->Story->findAll('complete =
0',null,null,null,null,-1) as $story) {
$comments[$story['story']['id']] =
array($this->Comment->findAll(
'story_id = ' + $story['story']['id'],
'content',
'created_at desc',
$story['viewablecomments'],
1,
-1)); // set recursive false
}
$this->set('comments', $comments);
thanks
On Feb 9, 10:15 pm, Mech7 <[EMAIL PROTECTED]> wrote:
> Ummm it does give allot of overhead to request all comments and only
> display a few... especially on a high traffic site.
>
> On Feb 9, 8:00 pm, MonkeyGirl <[EMAIL PROTECTED]> wrote:
>
> > > I want to return only a number of comments (that is defined in
> > > "visiblecomments") in every story.
>
> > This seems like an odd way of doing it, as you'd be able to specify
> > how many comments to retrieve, but not which ones... but yes, it's
> > certainly possible.
>
> > In your story controller, if your use of findAll is set to recurse, it
> > will automatically pull out all of the comments relating to that
> > story. Presumably, you're using a foreach on this information in the
> > view, so you could just limit it to stop once the visiblecomments
> > value has been reached.
>
> > There are more advanced ways of doing it, such as overriding afterFind
> > in the stories model to append the right number of comments, but it's
> > probably easier to do it the first way instead. :)
>
> > Hope that helps,
> > Zoe.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---