• Resolved amoswright

    (@amoswright)


    I love nextGen, and wanted to be able to pass some flashvars that aren’t supported by the wp plugin (i think), like link and linktarget. To use these flashvars, I also needed to create the show from a playlist, but wanted the playlist to still be manage-able from the wp nextGen admin interface. In case anyone else has the same needs, here is what worked for me. Not extensively tested… Probably a better way… but here it is:

    1) created a new template within my theme, I chose to make it for a specific page.

    2) create a blank, writeable playlist file, I chose to put this in my theme directory, extention can be xml or php (or whatever, I think).

    3) I chose to grab the script to create the slideshow by first putting the gallery I wanted to display on the page, then viewing source, then copying the entire <script></script> code, then later modifying it as needed.

    4) Then I added the playlist generation code, along with the modified slideshow generation code, into the page template.

    Here is the code that I put into the page template:

    <?php
    //if  you have custom table prefix, modify table name
    $query = "SELECT galleryid, filename, description, alttext, sortorder FROM wp_ngg_pictures WHERE galleryid like '2' order by sortorder asc";
    $results = $wpdb->get_results($query, OBJECT);
    
    $myFile = "/path/from/root/to/your/playlist.xml";
    $fh = fopen($myFile, 'w') or die("can't open file");
    // third, build the playlist
    //$stringData =  "header("content-type:text/xml;charset=utf-8")\n";
    $stringData =  "<playlist version='1' xmlns='https://xspf.org/ns/0/'>\n";
    $stringData .=  "<trackList>\n";
    foreach($results as $result){
    $stringData .=  "\t<track>\n";
    $stringData .=  "\t\t<title>".$result->alttext."</title>\n";
    $stringData .=  "\t\t<location>https://yourdomain.com/yourGalleryUploadLocation/yourGallery/".$result->filename."</location>\n";
    $stringData .=  "\t\t<info>https://www.linktosomewhereyouwnattosendhtem.com</info>\n";
    $stringData .=  "\t</track>\n";
    }
    $stringData .=  "</trackList>\n";
    $stringData .=  "</playlist>\n";
    fwrite($fh, $stringData);
    fclose($fh);
    ?>
    <div id="introslideshow">
    <div id="ngg_slideshow2">This text will be replaced</div>
    </div>
    <script defer="defer" type="text/javascript">
    
     var so2604 = new SWFObject("https://www.yourdomain.com/wp-content/plugins/nextgen-gallery/imagerotator.swf", "ngg_slideshow2", "500", "500", "7", "#000000");
     so2604.addParam("wmode", "opaque");
     so2604.addVariable("file", "https://www.yourdomain.com/path/to/playlist/file/playlist.xml");
    //lots of addVariables here, depending upon your settings...
     so2604.addVariable("link", "yourURLtoSendEmTo");
     so2604.addVariable("linktarget", "_self");
     so2604.addVariable("linkfromdisplay", "true");
    
     so2604.write("ngg_slideshow2");
    
    </script>

    So, I’d be curious if there is a better way, but this seems to work and is not too hard to implement (though it was a bit of trouble shooting for me!).

    Thanks for the awesome plugin!

  • The topic ‘[Plugin: NextGEN Gallery] Pass flashvars to slideshow’ is closed to new replies.