Hi ...
after many hours I've "created" a slideshow which can use on an external (outside of cpg) website.
Before I try to explain what I've done, take a look here (scroll down to "Gallery") to see what this all about.
Ok ...
I use SlideshowIt plugin for CPG1.6.x as base for my script (thank you to ron4mac for this plugin !) and some code I found here: Display a random image on an external website.
All this together works (in my case with cpg 1.5.46 and PHP 7) ... and YES !!! ... I'm also surprised as you are
.
I've created a file called "slideshow.php" in the cpg folder with this code:
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery - RSS Feed //
// ------------------------------------------------------------------------- //
// Copyright (C) Dr. Tarique Sani //
// http://tariquesani.net/ //
// Adapted by djib to display a random photo - http://djib.biz //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// ------------------------------------------------------------------------- //
// Just put into the same directory as your coppermine installation //
// ------------------------------------------------------------------------ //
define('IN_COPPERMINE', true);
define('INDEX_PHP', true);
require('./include/init.inc.php');
//How many items you want to show in your get_photo script
if(isset($_GET['nb'])) {
$thumb_per_page=$_GET['nb'];
} else {
$thumb_per_page = 10;
}
$thumb_count = 10;
$lower_limit = 0;
if(isset($_GET['album'])){
$album = $_GET['album'];
}
//If it is a numeric album get the name and set variables
if ((is_numeric($album))){
$album_name_keyword = get_album_name($album);
$CURRENT_CAT_NAME = $album_name_keyword['title'];
$ALBUM_SET = "AND aid IN (".(int)$_GET['album'].")".$ALBUM_SET;
//Set the album to last uploaded
$album = 'lastup';
}
//If the album is not set set it to lastup - this is the default
if(!isset($album)){
$album = 'lastup';
}
//Changes these to point to your site if the following is not giving correct results.
$link_url = $CONFIG['ecards_more_pic_target']."displayimage.php?pos=-";
$image_url = $CONFIG['ecards_more_pic_target']."albums/";
$data = get_pic_data($album, $thumb_count, $album_name, $lower_limit, $thumb_per_page);
foreach($data AS $picture) {
$thumb_url = "$image_url$picture[filepath]$picture[filename]";
$description = '<a target="_parent" href="' . $link_url . $picture['pid'] . '"><img style="border-radius: 8px; border: 1px solid black; width: 100%;" class="mySlides w3-animate-fading" src="' . $thumb_url . '"/></a>';
echo $description;
}
?>
<script>
var myIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
myIndex++;
if (myIndex > x.length) {myIndex = 1}
x[myIndex-1].style.display = "block";
setTimeout(carousel, 5000);
}
</script>
Then I put this code in my index.php in my website root:
<div class="w3-content w3-section" style="background-color: none;">
<iframe style="height: 380px; width: 500px;" src="cpg15x/slideshow.php" name="header_frame" marginheight="0" marginwidth="0" frameborder="0" scrolling="no"></iframe></div>
I don't know but maybe this is helpful for others ...
Very interesting, it works perfectly for me on my main CPG page (I haven't tried it outside of CPG, at the moment). A couple of queries;
Instead of using "lastup", would it be possible to use a specific album? I know that the php file allows it but I don't know what option I would have to change and I would like to create an album specifically for the Slideshow, like horizontal images and a very specific measure.
For example, I would like to use the images contained in this album:
Álbum 45What would the code look like in this case?
And another question, the code allows the link in each of the SlideShow images (it takes you to the specific image), would it be possible not to have the Link active?, the album that will supply images to the SlideShow will be private, the user when visiting the Link will not be able to enter.
Thanks, this looks great
