I need to create a comments sections for user profiles with the
following table design
Comment.id
Comment.user_id_to
Comment.user_id_from
So when I'm viewing a Users profile I can see all the comments made on
that profile.
I'm stumped on how to build the model what I have right now on the
users model is
--------------Model--------------------
class Profile extends AppModel {
var $name = 'Profile';
var $displayField = 'name';
var $hasMany = array(
'Comment'=>array(
'className'=>'Comment',
'foreignKey' => 'profile_id_to',
'order' => 'Comment.date DESC',
'limit' => '5',
'fields' => array(
'Comment.profile_id_from', 'Comment.description',
)
)
--------------------------Controller ---------------------------------
$this->Profile->find('first',array('conditions'=>array('Profile.id'=>
$id)));
----------------------------View-------------------------------------
foreach ($profile['Comment'] as $index => $comment) {
echo "Name:". $comment['profile_id_from']."<br/>";
echo $comment['description']."<br/>";
}
All the comments under a profile show up just fine but instead of
showing the Profile Name its shows me the profile_id_from value.. any
idea how to get it to show the name
Thanks in advance
IB
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment