We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10226
    • 412 Posts
    This snippet is still in the works, and is fairly specialized for my needs. Dimmy has been nice enough to help me so far. It is based on the MooSlidshow snippet, also by Dimmy.

    In my case;

    [!lightshow? &folder=`[+title+]` &set_name=`[+title+]` &sometv=`[+title+]`!]

    The page title is the folder, and the lightshow identifier, and the alternative text for the link...

    <?php
    $path = "slide/babies/$folder/";
    $slides = array();
    if ($dh = @opendir($path)) {
      while(($file = readdir($dh)) !== false) {
         if ( !preg_match('/\.thumb*/',$file) && preg_match('@.png$|.gif$|.jpg$|.PNG$|.GIF$|.JPG$@', $file) && $file != '.' && $file != '..' && $file != 'thumb.jpg') {
          $slides[] = $file;
        }
      }           
    }
    // shuffle($slides); //Enable random
    $num = count($slides);
    $output = "";
    for($i=0;$i<$num;$i++) {
      $output .= "<a href='$path$slides[$i]' rel='lightbox[$set_name]' title='[+species+] - [+title+] $[+price+]' >.</a> <br />";
    }
    return $output;
    ?>


    At this point, specifying a folder name will read the images from said folder and populate the links. The links (except the initial one) is meant to display as a "." in a hidden area of the page, or behind the thumbnail.

    I have tinkered around quite a bit and I can not get it to work properly; I need the thumbnail as a lightbox link to trigger the show. I can get it to work somewhat, but it appears my TV’s are being ignored on that certain call. Other than this, everything is working.

    The bunk output is
    <img alt=" Thumbnail" src="slide/babies//thumb.jpg"/>
    as taken from firebug. It should look like this
    <img alt="[b]FOLDER[/b] Thumbnail" src="slide/babies/[b]FOLDER[/b]/thumb.jpg"/>
    FOLDER being the ’title’ TV. Somewhere in there I need it to create the lightbox link from the [+title+]/thumb.jpg image. I did get this to work, but it displayed it once for every image in the folder... I am not by any means a coder, but I have made some fair mods and fixes to the original code provided to me. Here is the code that I need in here somewhere;

    <a href="slide/babies/[+title+]/FIRST IMAGE"><img src="/slide/babies/[+title+]/thumb.jpg" alt="[+title+] Thumbnail" /></a>
    Well I guess there was one more step than I thought, isolating the first image - since thumb.jpg is actually a thumbnail and the other images are not thumbnail size. This is to simplify things, making one thumbnail instead of a thumbnail for every image. If someone wanted to go crazy and inline direct resize in here that would be really awesome, but I’m dreaming.

    This is a simple but useful snippet. I hope we can get this finished so others may use it.

    Thanks!

      • 7455
      • 2,204 Posts
      again call it like this:
      [!lightshow? &folder=`[*title*]` &set_name=`[*title*]` &sometv=`[*title*]`!] instead of this:
      [!lightshow? &folder=`[+title+]` &set_name=`[+title+]` &sometv=`[+title+]`!]

      dimmy
        follow me on twitter: @dimmy01
        • 10226
        • 412 Posts
        Ahh, I did not understand what you were saying, I was using *’s in the wrong place - obviously to no avail...

        I am still left with a few problems, such as the firstimage issue. My current method, would hardcode ’thumb.jpg as the link, and this will make it the first image shown in the lightbox, thus defeating the exclusion of it in the snippet... but I will see how far I can get this time around.

        Thanks!

        using the *’s does not work, and this is being called via ditto as well...
        using *’s does work when calling with [[ instead of [!...
          • 10226
          • 412 Posts
          Now I have a few problems smiley

          if I throw in this;

          print "<a href='$path$slides[$i]' rel='lightbox[+title+]' title='[+species+] - [+title+] $[+price+]' class='opac'><img src='slide/babies/[+title+]/thumb.jpg' alt='[+title+] Thumbnail'/></a>";


          The TV’s do not work / carry over

          And when I call;

          [[lightshow? &folder=`[*title*]` &set_name=`[*title*]` &sometv=`[*title*]`]]


          I get no links, the snippet does not output anything.

          I’m a bit confused... if it helps I am calling this from [[ditto]].

          SOLVED - posting completed code in a new post smiley
            • 10226
            • 412 Posts
            main snippet;

            <?php
            $path = "slide/babies/$folder/";
            $slides = array();
            if ($dh = @opendir($path)) {
              while(($file = readdir($dh)) !== false) {
                 if ( !preg_match('/\.thumb*/',$file) && preg_match('@.png$|.gif$|.jpg$|.PNG$|.GIF$|.JPG$@', $file) && $file != '.' && $file != '..' && $file != 'thumb.jpg') {
                  $slides[] = $file;
                }
              }           
            }
            print "<a href='$path$slides[1]' rel='lightbox[[+title+]]' title='[+species+] - [+title+] $[+price+]' class='opac'><img src='slide/babies/[+title+]/thumb.jpg' alt='[+title+] Thumbnail'/></a>";
            // shuffle($slides); //unhash this line for random
            $num = count($slides);
            $output = "";
            for($i=0;$i<$num;$i++) {
              $output .= "<a href='$path$slides[$i]' rel='lightbox[$set_name]' title='[+species+] - [+title+] $[+price+]' >.</a> <br />";
            }
            return $output;
            ?>


            as called from [[ditto]] with;

            [[lightshow? &folder=`[+title+]` &set_name=`[+title+]` &sometv=`[+title+]`]]


            Now I see we have a bit of redundancy, but those strings can be easily used for more custom modifiers. The next level would be to call directresize from within the snippet to gen the thumbnail. I have not looked at directresize, but if anyone thinks it would be easy to do, let me know and I might give it a go.

            Thanks everyone smiley

            bugfix -

            print "<a href=’$path$slides[1]’ rel=’lightbox[[+title+]]’ title=’[+species+] - [+title+] $[+price+]’

            should be

            print "<a href=’$path$slides[0]’ rel=’lightbox[[+title+]]’ title=’[+species+] - [+title+] $[+price+]’

            I’m sure you coders noticed that one smiley - this will bork the link if there is only one image file in the folder.
              • 7455
              • 2,204 Posts
              mm why not use maxigallery if you want to do resizing etc?
                follow me on twitter: @dimmy01
                • 10226
                • 412 Posts
                The resize was just an idea, the pictures are all static sizes... the images are all processed with photoshop scripts before they are uploaded.