6
I’m trying to make a gallery, which consists of a list of thumbnails, which by clicking on the items would eventually make a popup window appear as in first example here.
After several failed attempts, where even thumbnails did not appear, at the suggestion of other people, I tried to solve this problem with the plugin Cakephp-Fancybox, that partially solved my problem. However, by clicking on the thumbnails the user is redirected to another page that shows the original image, instead of floating on the thumbnail page.
After solving the various errors related to not finding javascript and reinstalling the Fancybox Plugin for Cakephp, the lightbox does not appear. How can these situations be solved?
Controller Action:
public function ShowImages(){
$this->layout = 'default';
$this->loadModel('GalleryImage');
$gallery_images = $this->GalleryImage->find('all');
$this->set('gallery_images', $gallery_images);
//$image_display = $gallery_image['path']
}
View:
<h2>Galeria</h2>
<br>
<table width="100%">
<tr>
<?php
$i=0;
foreach( $gallery_images as $gallery_image ):?>
<td align="center" class="thumbnail" style="display:inline-block;">
<?php
$src3 =$this->webroot. 'img/gallery/' .$gallery_image['GalleryImage']['path'];
//$src3 = 'img/gallery/' .$gallery_image['GalleryImage']['path'];
$this->Fancybox->setProperties( array(
'class' => 'fancybox3',
'className' => 'fancybox.image',
'title'=>'Single Image',
'rel' => 'gallery1'
)
);
$this->Fancybox->setPreviewContent($this->Timthumb->image('/img/gallery/' . $gallery_image['GalleryImage']['path'] , array('width' => 267, 'height' => 189)));
$this->Fancybox->setMainContent($src3);
echo $this->Fancybox->output();
?>
</td>
<?php $i++;
if($i==4){
echo "</tr><tr>";
$i=0;
}
?>
<?php endforeach ?>
</tr>
Layout (head):
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title><?php echo $title_for_layout;//titulo dinamico da página?></title>
<?php
echo $this->Html->meta('icon');
//echo $this->Html->css('cake.generic');
echo $this->fetch('meta');
echo $this->fetch('css');
echo $this->Html->script('jquery-1.11.0.min');
echo $this->Html->script('main');
echo $this->Html->css('main');
echo $this->Html->script('modernizr-2.6.2-respond-1.1.0.min');
echo $this->Html->css('bootstrap-theme.min');
echo $this->Html->css('bootstrap.min');
echo $this->Html->css('bootstrap');
echo $this->Html->script('bootstrap.min');
echo $this->Html->script('bootstrap');
echo $this->Html->script('dropdown');
echo $this->Html->script('collapse');
?>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<style>
body {
padding-top: 50px;
padding-bottom: 20px;
}
</style>
<script type="text/javascript">
$(function(){
$(".dropdown-toggle").click(function(){
$(this).dropdown('toggle');
});
});
</script>
<script type="text/javascript" src="/fancybox/source/jquery.fancybox.pack.js?v=2.1.5">
$(document).ready(function () {
$(".fancybox3").fancybox(e){
openEffect : 'none',
closeEffect : 'none',
helpers : {
title : {
type : 'float'
}
}
e.preventDefault;
});
});
</script>
</head>
While editing the indentation, I could see the following problems:
<?php $i++;
is not closed, in classGalleryController
has a}
plus, I haven’t removed it to not change the code posted, but it’s worth just reviewing =).– Icaro Martins
I’m sorry, it was mistakes copying the code, I fixed them.
– SunT
post the output of your html
– Igor Martins
Okay thanks, this is the first time I’ve used something like Stack, I’m sorry.
– SunT
@Igormartins already posted it.
– SunT