0

I have a problem with adjusting the gallery plugin in CakePHP. (to be more specific this plugin: https://github.com/barman789/cakephp_gallery_plugin). I managed to run this plugin in seperate site by adding in routing.php:

Router::connect('/:language/gallery', array('plugin' => 'gallery_manager', 'controller' => 'albums', 'action' => 'index'),array('language' => implode('|', $languages)));
Router::connect('/:language/gallery/add/*', array('plugin' => 'gallery_manager', 'controller' => 'albums', 'action' => 'add'),array('language' => implode('|', $languages)));

I have already created page with 'News' page where i can add posts in admin mode etc. but i would like to have and option to add gallery to every post with option to add/delete images in it. I wanted to include element in each post by putting:

<?php echo $this->element('GalleryManager.gallery', array('result' => $result)); ?>

but i keep getting error:

Notice (8): Undefined variable: result [APP/View/Dogs/index_psy.ctp, line 37]

Warning (2): Invalid argument supplied for foreach() [APP/Plugin/GalleryManager/View/Elements/gallery.ctp, line 10]

I spent alot of time searching for solution to this problem or looking for some other option how to make this gallery. I would appreciate any help solving this or finding new idea how to do it. Thanks alot in advance!

Shishibi
  • 53
  • 10
  • 2
    I assume `$result` is actually being set? – Ross Apr 20 '14 at 19:16
  • $result is set in plugin controller in action show. `public function show($id = null) { $result = $this->GalleryAlbum->find('first', array('conditions' => array('GalleryAlbum.id' => $id, 'GalleryAlbum.deleted' => 0), 'contain' => 'GalleryImage')); if(empty($result)) { throw new NotFoundException('Not Found'); } $this->set('result', $result); }` – Shishibi Apr 20 '14 at 20:49
  • Based on information provided you set `$result` in the `show` method, yet your `view` is `index_psy.ctp` `$result` needs to be set in the `index_psy` method, unless you are doing something else. – Ross Apr 20 '14 at 21:42
  • $result is set in AlbumsController (in method Show) which is part of the plugin. I cannot move just a part of plugin to index_psy method. There has to be some way to solve it otherwise this plugin is useless to be honest... Maybe someone has other solution how to make gallery in every post in News section on my website? I'm quite desperate right now – Shishibi Apr 20 '14 at 23:44

0 Answers0