I have a gallery model that has many photos, and in my gallery view I'm finding the gallery by $slug. I'm displaying all the photos that belong to a specific gallery_id. This is working as expected.
However, I'd like to add a condition to the query that only returns the photos if the photo.active => 'yes'.
What I'm finding is that because the gallery view is found by $slug, my attempts to filter the photos isn't working. In the photos model I save the gallery_id and not the gallery.slug.
I've tried to use containable in the gallery controller but I'm getting the following errors when using this controller find:
$galleryphotos = $this->Gallery->Photo->find('all', array(
'contain' => array('Photo'),
'conditions' => array(
'gallery.slug'=> $slug,
'photo.active'=>'yes')));
Error I get in the view:
Warning (512): Model "Photo" is not associated with model "Photo"
Is adding a gallery.slug column to the photos model the best way to query photos with conditions?
Also, why do I get the error when using containable in the gallery controller?
Cheers, Paul