another fairly basic question I suppose, but I feel like I'm running in circles and out of ideas, haha.
I'm trying to create a commenting system with pagination (via Ajax), which has to be able to display the name, avatar, etc. of the user that wrote a particular comment. Sounds simple enough, right?
Well, everything works fine, except so far I simply wasn't able to find a way to retrieve the corresponding users information and I couldn't find anything helpful in the docs either.
Here's my pagination code so far:
$this->paginate['Comment'] = array(
'conditions'=>array('Entry.id'=>$id),
'contain' => array('Entry', 'User'=>array('avatar', 'username') ),
'limit' => 10
);
$comments = $this->paginate('Comment');
$this->set(compact('comments'));
So I've used contain to get the data of the user model, which I try to display in my view like this:
echo $comment['User']['username'];
echo $comment['User']['avatar'];
But that way, it of course displays the information of the user corresponding to $id...
However, I need to get a users info through the foreignkey user_id of the current comment. And at the moment I'm at a loss how to do that... Any help would be greatly appreciated. Thanks in advance!