We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22427
    • 793 Posts
    Hi all,

    it’s only yesterday that I found the very useful snippet [tt]FileDownload![/tt] (see http://modxcms.com/forums/index.php/topic,3124.0.html and http://modxcms.com/extras/package/?package=146).
    It helped me to populate the slideshow div containing the images for a simple slideshow created by the [tt]cycle[/tt] plugin for jQuery (see http://jquery.malsup.com/cycle/ ).

    Here’s a description of how it works for me - maybe one of you finds that helpful for her/his needs.

    (1)

    In the head of my template I have the following:

    <link href="[(base_url)]assets/css/screen/jqcycle.css" rel="stylesheet" type="text/css"/>
    <!-- include jQuery library -->
    <script type="text/javascript" src="[(base_url)]assets/js/jquery-1.3.2.min.js"></script>
    <!-- include Cycle plugin -->
    <script type="text/javascript" src="[(base_url)]assets/js/jquery.cycle.all.latest.js">
    </script>
    <script type="text/javascript">
    $(document).ready(function() {
        $('#[[GetField? &field=`cycle-name`]]').cycle({
    		fx: 'fade'
    	});
    });
    </script>
    

    You see that the necessary [tt]jQuery[/tt] files are located in the [tt]assets/js[/tt] directory. The identifier for the slideshow is taken from a TV [tt]cycle-name[/tt], associated with the template.
    The option values of this radio button TV are [tt]cycle1||cycle2||cycle3[/tt] and so on, where these names are identical with the subfolder names of a directory [tt]assets/images/jqcycles[/tt]. Being a subdirectory of [tt]assets/images[/tt], the directory [tt]jqcycles[/tt] is accessible and can be filled with picture files via the manager. (To make it simple, I assume that all images are of type [tt]jpg[/tt].)

    (2)
    In the template you just have to insert a chunk call [tt]{{jqc-div}}[/tt] at the position where you want to show up the slideshow. The chunk [tt]{{jpc-div}}[/tt] contains the call of the snippet [tt]FileDownload[/tt] which will create the slideshow div:
    [!FileDownload? &getFolder=`assets/images/jqcycles/[*cycle-name*]` &tplList=`jqc-imagelist-tpl` !]
    

    Again the TV [tt]cycle-name[/tt] is used to identify the wanted folder of pictures.
    The output is formatted by another chunk, [tt]jqc-imagelist-tpl[/tt] :
    <div class="jqc-show" id="[*cycle-name*]">
    <hr>
    <img src="[(base_url)]assets/images/jqcycles/[*cycle-name*]/[+filename+]">
    <hr>
    </div>
    

    Here the two [tt]<hr />[/tt] [1] [tt]<hr>[/tt] elements are obligatory for the [tt]FileDownload[/tt] snippet - they separate the "header" and the "footer" of its output from the "row template" between them. The source for each picture is the path of the chosen cycle-folder followed by the [tt][+filename+][/tt] placeholder of [tt]FileDownload[/tt]. So the snippet automatically picks up every image file in that folder - whatever their filenames may be.

    (3) It works like a treat!


    Best wishes to all of you
    ottogal

    [1] Edit: The seperators in the template have to be [tt]<hr>[/tt] , not [tt]<hr />[/tt] .



      • 26016
      • 561 Posts
      Very clever, thank you!

      It’s so cool when you’re able to get a thickbox and other photo goodies and effects with a nice light Javascript solution!
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 22427
        • 793 Posts
        (see http://modxcms.com/forums/index.php/topic,3124.0.html and http://modxcms.com/extras/package/?package=146)
        I realized later that I used the ancient version 1.6 found in the cited thread and not the newest version of the mentioned package.
        Using FileDownload 2.6 the code of the chunk [tt]jqc-imagelist-tpl[/tt] should, of course, be the following:
        <div class="jqc-show" id="[*cycle-name*]">
        <!-- Fd:Splitter -->
        <!-- Fd:Splitter -->
        <!-- Fd:Splitter -->
        <img src="[(base_url)]assets/images/jqcycles/[*cycle-name*]/[+fd.filename+]">
        <!-- Fd:Splitter -->
        <!-- Fd:Splitter -->
        <!-- Fd:Splitter -->
        </div>

          • 22427
          • 793 Posts
          [Sorry for the others: PM not working]

          @frenchman78:
          Ich hoffe, du schaust hier rein. Per PM zu antworten, klappt momentan nicht, k.A. weshalb.

          Zu deiner Frage, wie du verhindern kannst, dass auch die Thumbs angezeigt werden:

          [tt]FileDownload[/tt] schnappt sich alle Bilder aus dem im Parameter [tt]&getFolder[/tt] angegebenen Verzeichnis. Also müssen die thumbs dort raus. Bei mir liegen sie in einem Unterverzeichnis [tt]thumbs[/tt] des Bilderverzeichnisses. Da mir dann dieses auch als vermeintliche Bilddatei in die Liste aufgenommen wurde, habe ich noch den Parameter [tt]&showExt[/tt] benutzt: Mit [tt]&showExt=`jpg`[/tt] werden nur files mit der Endung [tt].jpg[/tt] ausgegeben, also nicht mein [tt]thumbs[/tt].
          Viel Erfolg weiterhin!

          ottogal