I have two models: ‘gallery’ and ‘image’. When I try to fetch images from the galleries_controller I see this error:
Notice (8): Undefined variable: images [APP\controllers\galleries_controller.php, line 25]
I use CakePHP’s find method to limit the images results.
Here is my galleries_controller:
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid image', true));
$this->redirect(array('action' => 'index'));
}
$this->set('gallery', $this->Galley->read(null, $id));
/// this code have some problem ///
$this->loadModel('image');
$Images= $this->Image->find('all',
array(
'limit' => 2, //int
)
);
$this->set('images', $images);
}
The variable name is case sensitive ($Images and $images need to be all lowercase or all uppercase)