This might be elementary for some, but I haven't quite wrapped my head
around how I can build a hasMany relationship from my app model to a
model in a plugin (one I'm also writing).

The basic gist looks something like this:

/** App's User Model **/
class User extends AppModel {
        var $name = 'User';
        var $hasMany = array('Gallery.Gallery'); // you get the point
}

/** Gallery Plugin's Gallery Model **/
class Gallery extends GalleryAppModel {
        var $name = 'Gallery';
        var $belongsTo = array( ... ); //other plugin models

}

/*********************************************************/

So what I want to do is basically get a list of all the galleries
associated with a user. I know how to do that if the gallery is built
in to the app, but since I'm trying to make it modular I'm a little
stumped. PS: There are other app models that will also have a hasMany
relationship to gallery, so I want to do the right thing.

I'm in the mindset that plugins aren't meant to be messed with (too
much) to integrate them into your app, so it doesn't seem like a good
idea to me to start adding foreign key fields in the gallery model
(like user_id or tag_id).  I considered creating a HABTM on my app
side so I at least have a join table where I can match the two sets of
foreign keys. Am I wrong about either of these?

So the big question - How do I do this? Does anyone else figured this
out before?

Thanks so much in advance! This community has been very good to me in
the past.

~Cameron

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to