On Wed, Nov 28, 2012 at 12:30 AM, Chris <[email protected]> wrote:
> I don't think it's possible to do that,... each Model has its own
> comments,... and there is not only Blogs and Photos, there are Groups,
> Videos, Dba, etc,...

Comment:

public $belongsTo = array(
        'User',
        'Blog' => array(
                'className'  => 'Blog',
                'conditions' => array(
                        'Comment.foreign_key' => 'Blog.id',
                        'Comment.model' => 'Blog'
                ),
                'foreignKey' => false
        ),
        'Photo' => array(
                'className'  => 'Photo',
                'conditions' => array(
                        'Comment.foreign_key' => 'Photo.id',
                        'Comment.model' => 'Photo'
                ),
                'foreignKey' => false
        ),
        ...
);

Blog:

public $hasMany = array(
        'Comment' => array(
                'className' => 'Comment',
                'foreignKey' => 'foreign_key',
                'conditions' => array('Comment.model' => 'Blog'),
                'dependent' => true
        )
);

etc.


> and I need to display them on Home page on first come
> first served bases

Then you would only need to order them by created date.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to