How do I tell CakePHP 1.3 to pull all images that have the same gallery_id matching the gallery_id of the current Image View? I am trying to find all images for a Gallery using FindAllByGalleryId. In the view there is one big picture for the image view, and thumbnails below it of all other images in the same gallery.
Everything works when I enter an actual Gallery ID number (as shown here), but that Gallery ID number changes depending on which Gallery is being viewed – so I don’t want it to be set to a specific number – I want it to match the gallery_id of the image being viewed.
$this->set(
'all_images',
$this->Image->findAllByGalleryId('2')
);
What is needed is to set the current gallery_id as the variable and then tell the Find conditions to match it. Problem is that I don’t have the right syntax, so the error comes up that the gallery_id variable does not exist.
I have tried setting find conditions to ‘Image.gallery_id’ => ‘$gallery_id’ and similar stabs at identifying the current item’s gallery_id to be matched, but I’m clueless after working at this for some time. Any direction would be greatly appreciated!!!
Try using
$this->set('all_images', $this->Image->findAllByGalleryId($this->Image->data['Image']['gallery_id']));