Note that there are some explanatory texts on larger screens.

plurals
  1. POFancybox: Nav buttons not showing, content in a PHP array
    primarykey
    data
    text
    <p>I have a little problem with an images gallery on Fancybox 2.0.6. I have no nav buttons showing, only the close one. So, I guess that I've made a mistake when I added the plugin in my gallery script so that it finds only one image. The problem isn't depending of the browser used, I get it on IE, Firefox, Safari, Chrome and Opera. My gallery script is in PHP, like all the rest of my site. My images are stored in an array, created by a function which reads the folder content.</p> <p>Here are my scripts.</p> <p>Function get_files:</p> <pre><code>// Fonction de lecture du dossier et publication dans un tableau function get_files($images_dir,$exts = array('jpg')) { $files = array(); if($handle = opendir($images_dir)) { while(false !== ($file = readdir($handle))) { $extension = strtolower(get_file_extension($file)); if($extension &amp;&amp; in_array($extension,$exts)) { $files[] = $file; } } closedir($handle); } return $files; } </code></pre> <p>portfolio.php (gallery part)</p> <pre><code>$image_files = get_files($images_dir); if(count($image_files)) { $index = 0; $firstimage = $image_files[0]; $thumb = $images_dir.'/'.$firstimage; //Lien: files/photos/$images_dir/premièreimage.JPG $page .= '&lt;script type="text/javascript"&gt;'; $page .= '$(".img_gallery").click(function() {'; $page .= '$.fancybox.open(['; foreach($image_files as $index=&gt;$file) { $index++; // echo $file.'&lt;br /&gt;'; //Création des liens image pour javascript $link = $images_dir.'/'.$file; $page .= "{ href : '".$link."', title : '".$altname."' } ],"; } // Création des liens de la galerie et fermeture du dossier $page .= '});&lt;/script&gt;'; $page .= '&lt;h3&gt;Open Gallery&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;'; $page .= '&lt;a class="img_gallery" href="'.$thumb.'" rel="gallery"&gt;&lt;img src="'.$thumb.'" height="342" width="512" alt="Open Gallery" title="Open Gallery"/&gt;&lt;/a&gt; '; } else { $page .= '&lt;p&gt;There are no images in this gallery.&lt;/p&gt;'; } </code></pre> <p>And here are the lines where I added the plugins:</p> <pre><code>&lt;!-- Add jQuery library --&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"&gt;&lt;/script&gt; &lt;!-- Add mousewheel plugin (this is optional) --&gt; &lt;script type="text/javascript" src="fancybox/lib/jquery.mousewheel-3.0.6.pack.js"&gt;&lt;/script&gt; &lt;!-- Add fancyBox --&gt; &lt;script type="text/javascript" src="fancybox/source/jquery.fancybox.pack.js"&gt;&lt;/script&gt; &lt;!-- Add Button helper (this is optional) --&gt; &lt;script type="text/javascript" src="fancybox/source/helpers/jquery.fancybox-buttons.js"&gt;&lt;/script&gt; &lt;!-- Add Thumbnail helper (this is optional) --&gt; &lt;script type="text/javascript" src="fancybox/source/helpers/jquery.fancybox-thumbs.js"&gt;&lt;/script&gt; &lt;!-- Add Media helper (this is optional) --&gt; &lt;script type="text/javascript" src="fancybox/source/helpers/jquery.fancybox-media.js"&gt;&lt;/script&gt; &lt;!-- Gallery Initiators --&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { /*$("a[rel='gallery']").fancybox();*/ $("a[rel='gallery']").fancybox(portfolio,{ openEffect : 'elastic', closeEffect : 'elastic', nextEffet: 'fade', prevEffect: 'fade' }); }); &lt;/script&gt; </code></pre> <p>Could anyone explain me what's wrong and how to correct this ? I've got good skills in PHP, but I'm quite newbie to Javascript. Some details more: I cannot create each link for each image, I've got many galleries (set by a $_GET value) and some contain hundred and more images. Finally, I would like to have only the first image of each gallery showing on the page as the gallery link (manual call).</p> <p>Many thanks in advance !</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload