View Full Version : Help with code to create an array from contents of folder
Jim Weinberg
04-15-2014, 02:01 PM
I recently upgraded a webpage using Ultimate Fade-in Slideshow script from version 1.5.1 to version 2.4. With the previous version I used a PHP script to build an array of photos from the contents of a folder. Here's the code (John, if you're reading this, I believe you gave me this code):
<?php
//call line: <script type="text/javascript" src="a/build_array.php?folder=b&array=c&usefilenames=d"></script>
// where a=relative location of the php script file
// b=relative location of graphics folder
// c=name of array to be built
// d=use file names as captions:yes|no
Header("content-type: application/x-javascript");
function returnimages($arrayname) {
$dirname="../" . $_GET["folder"] . "/";
$pathname="" . $_GET["folder"] . "/";
$pattern="\.(jpg|jpeg|png|gif|bmp)$";
$curimage=0;
$str=',""';
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)){
if($_GET["usefilenames"]=='yes')
$str = ', "' . preg_replace('/\.[^\.]*$/', '', $file) . '"';
echo $arrayname . '[' . $curimage .']=["' . $pathname . $file . '", "", ""' . $str . '];' . "\n";
$curimage++;
}
}
closedir($handle);
}
}
$arrayname=$_GET["array"];
echo 'var ' . $arrayname . '=new Array();' . "\n";
returnimages($arrayname);
?>
The array name was then passed to the slideshow script as a parameter in the call.
The new slide show version has the array as an option:
var ShowPics=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [400, 300], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
["Graphics/ShowPics/100_0466-A.jpg"],
["Graphics/ShowPics/100_0467-A.jpg"],
["Graphics/ShowPics/100_0469-A.jpg"],
["Graphics/ShowPics/100_0470-A.jpg"],
["Graphics/ShowPics/100_0471-A.jpg"],
["Graphics/ShowPics/100_0472-A.jpg"]
],
displaymode: {type:'auto', pause:2000, cycles:1, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "none",
togglerid: ""
})
What I'd like to do is replace the imagearray option and array definition with an array built by the PHP routine. I'm not a PHP coder, and really have no idea how to accomplish this.
Can someone please help me with this?
Thanks.
Beverleyh
04-15-2014, 02:59 PM
This should do it - paste the PHP in green and blue in place of the JS array on your page;
var ShowPics=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [400, 300], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
<?php
$dir = '/home/www/website.com/Graphics/ShowPics/'; // root path to images
$path = 'Graphics/ShowPics/'; // path to echo in to page
$patterns = '\.(jpg|jpeg|png)$'; // only these file types
if($hd = opendir($dir)){
while(false !== ($fname = readdir($hd))){
if(ereg('^\.{1,2}$',$fname)) continue; // exclude current directory, parent directory
if(! ereg($patterns,$fname)) continue; // exclude file types not in $patterns
$files_array[] = $fname;
}
}
sort($files_array); // sort files a-z
for ($i = 0; $i < count($files_array); $i++) {
$comma = ($i != count($files_array) - 1) ? ',' : ''; // if next item exists in array set $comma as ',' else '' (nothing)
echo "[\"$path$files_array[$i]\"]$comma<br/>";
}
closedir($hd);
?>
],
displaymode: {type:'auto', pause:2000, cycles:1, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "none",
togglerid: ""
})
Should output this;
var ShowPics=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [400, 300], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
["Graphics/ShowPics/100_0466-A.jpg"],
["Graphics/ShowPics/100_0467-A.jpg"],
["Graphics/ShowPics/100_0469-A.jpg"],
["Graphics/ShowPics/100_0470-A.jpg"],
["Graphics/ShowPics/100_0471-A.jpg"],
["Graphics/ShowPics/100_0472-A.jpg"]
],
displaymode: {type:'auto', pause:2000, cycles:1, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "none",
togglerid: ""
})
Remember to change the variables in blue. This should also be placed inside the web page rather than in an external file.
Jim Weinberg
04-15-2014, 03:19 PM
Hi Beverley.
Thank you so much for your help. That will definitely work. I see that you said to put the code in the web page, and I hope I'm not pressing my luck, but I have 7-10 different graphics folders and rather than replicate the PHP code in each slideshow definition (they're all on the same page), I'd really like to be able to put the common code in an external file and call it. Is that possible?
Beverleyh
04-15-2014, 04:11 PM
Yes, you should just be able to turn it in to a function and pass the variables to it.
(untested)
Put this in an external .php file (e.g - "slide-array-function.php");
<?php
function imageSlideArray($dir, $path) {
//$dir = '/home/www/website.com/Graphics/ShowPics/'; // root path to images
//$path = 'Graphics/ShowPics/'; // path to echo in to page
$patterns = '\.(jpg|jpeg|png)$'; // only these file types
if($hd = opendir($dir)){
while(false !== ($fname = readdir($hd))){
if(ereg('^\.{1,2}$',$fname)) continue; // exclude current directory, parent directory
if(! ereg($patterns,$fname)) continue; // exclude file types not in $patterns
$files_array[] = $fname;
}
}
sort($files_array); // sort files a-z
for ($i = 0; $i < count($files_array); $i++) {
$comma = ($i != count($files_array) - 1) ? ',' : ''; // if next item exists in array set $comma as ',' else '' (nothing)
echo "[\"$path$files_array[$i]\"]$comma<br/>";
}
closedir($hd);
}
?>
Then on your web page, include the function file at the top;
<?php include('path/to/slide-array-function.php');?>
And call it like this;
var ShowPics=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [400, 300], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
<?php imageSlideArray('/home/www/website.com/Graphics/ShowPics/', 'Graphics/ShowPics/');?>
],
displaymode: {type:'auto', pause:2000, cycles:1, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "none",
togglerid: ""
})
Beverleyh
04-15-2014, 04:23 PM
Just a note - ereg() (http://www.php.net/manual/en/function.ereg.php) was deprecated from PHP v5.3.0
I say now because I realised after I copied and paste part of the code above from one of my older websites running v5.2.?
Depending on the version of PHP you (or anyone looking in on this thread) is using, you might need to replace these lines;
replace;
$patterns = '\.(jpg|jpeg|png)$'; // only these file typeswith;
$patterns = '/\.(jpg|jpeg|png)$/'; // only these file types
replace;
if(ereg('^\.{1,2}$',$fname)) continue; // exclude current directory, parent directory
if(! ereg($patterns,$fname)) continue; // exclude file types not in $patterns with
if(preg_match('/^\.{1,2}$/',$fname)) continue; // exclude current directory, parent directory
if(!preg_match($patterns,$fname)) continue; // exclude file types not in $patterns
Jim Weinberg
04-15-2014, 05:40 PM
Beverley.
Tried your recommendations, but no go. The PHP routine, which I called build_array.php, is exactly as you specified. Here's the code from the webpage:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<?php include('http://www.ohiobuttons.org/test/Script_Files/build_array.php');?>
<script type="text/javascript" src="Script_Files/fadeslideshow.js">
/***********************************************
* Ultimate Fade In Slideshow v2.0- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>
<script>
var ShowPics=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [400, 300], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
<?php imageSlideArray('http://www.ohiobuttons.org/Graphics/ShowPics/CurrentShow/', 'http://www.ohiobuttons.org/Graphics/ShowPics/CurrentShow/');?>
],
displaymode: {type:'auto', pause:2000, cycles:1, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "none",
togglerid: ""
})
</script>
</head>
The Body's the same as before (with the original array definition).
BTW, I made the other code replacements you suggested.
Thanks.
Beverleyh
04-15-2014, 06:13 PM
The first variable path in the imageSlideArray() and the path in the include() need to be a server path rather than http ones used in HTML.
They'll look something like this;
/home/www/mywebsite.com/images/
/home/user/public_html/images/
/www/user/mywebsite.com/images/
If you're not sure, check in your web hosts control panel. There are ways to do it using $_SERVER variables in PHP but I'm on the road now so can't give examples. If you Google something like "finding server paths" you'll find more info though.
Jim Weinberg
04-15-2014, 07:55 PM
Beverley.
I think I know what you're referring to. I changed the include to:
<?php include('test/Script_Files/build_array.php');?> and the function call to:
<?php imageSlideArray('test/Graphics/ShowPics/', 'Graphics/ShowPics/');?>.
These are the server paths relative to the invoking webpage.
If that's right, then it's something else as the page still doesn't show the slides.
If it's not right, then I'll have to call the server people tomorrow (couldn't do it today).
jscheuer1
04-15-2014, 08:08 PM
If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
Beverleyh
04-15-2014, 09:02 PM
Try using full and absolute server paths while you troubleshoot - those are the ones like I posted earlier. The ones you're using are relative so they might not be resolving properly/as expected.
Also, it sounds obvious, but make sure your page ends with the .php extension and not .htm or .html (unless your server is setup to parse PHP on HTML pages). PHP can't run on a static HTML page so that could be throwing a spanner in the works before you've even started.
Failing that, yes, please post a link to your page.
Jim Weinberg
04-16-2014, 12:49 PM
Okay, here's the link to the page I'm trying to get working: http://ohiobuttons.org/test/NewFadinSlideShow_1.html
Beverley. I tried putting it up as a .php page, but it displays a blank page. Also, I tried every combination I could think of using the examples you gave me. Nothing worked. I still haven't been able to get a hold of my server's tech support people. I'll keep trying.
Beverleyh
04-16-2014, 02:04 PM
At this stage I think you should go back to basics and confirm that the PHP is working for you. I've tested this code here and it works fine for me (in a page called "test.php");
<?php
function imageSlideArray($dir, $path) {
//$dir = '/home/www/mywebsite.com/images/';
//$path = 'Graphics/ShowPics/';
$patterns = '/\.(jpg|jpeg|png)$/'; // only these file types
if($hd = opendir($dir)){
while(false !== ($fname = readdir($hd))){
if(preg_match('/^\.{1,2}$/',$fname)) continue; // exclude current directory, parent directory
if(!preg_match($patterns,$fname)) continue; // exclude file types not in $patterns
$files_array[] = $fname;
}
}
sort($files_array); // sort files a-z
for ($i = 0; $i < count($files_array); $i++) {
$comma = ($i != count($files_array) - 1) ? ',' : ''; // if next item exists in array set $comma as ',' else '' (nothing)
echo "[\"$path$files_array[$i]\"]$comma<br/>";
}
closedir($hd);
}
?>
<?php imageSlideArray('/home/www/mywebsite.com/images/', 'Graphics/ShowPics/');?>
Prints out this;
["Graphics/ShowPics/about.jpg"],
["Graphics/ShowPics/bookmark.jpg"],
["Graphics/ShowPics/calendar.jpg"],
["Graphics/ShowPics/cross.jpg"],
["Graphics/ShowPics/demo.jpg"],
["Graphics/ShowPics/display.jpg"],
["Graphics/ShowPics/exclamation.jpg"],
["Graphics/ShowPics/extras.jpg"]
jscheuer1
04-16-2014, 02:09 PM
It's unlikely that any PHP code on an HTML page will execute and the PHP code on that HTML page looks like it wouldn't do anything anyway. However, because not even build_array.php appears to work as advertised, unless that's been changed, it looks like PHP is not available on the server. But it might be something(s) else (permissions, bad coding, etc.) are you certain that PHP is available and turned on for that account? If so, does it have directory reading permission? Why is the index PHP file 'unavailable'? I can see it right there in folder view, that almost must be a permission issue at least for that file.
jscheuer1
04-16-2014, 02:39 PM
Beverly, we cross posted. Your code works here also. And I agree there is some doubt PHP is available. In your code I would add case insensitivity to the pattern:
$patterns = '/\.(jpg|jpeg|png)$/i'; // only these file type
and possibly other image types (bmp, gif).
Oh. and you cannot use <br> in javascript like that:
echo "[\"$path$files_array[$i]\"]$comma<br/>";
Use a line break:
echo "[\"$path$files_array[$i]\"]$comma\n";
It won't look so pretty on the page, but will look fine in source view, which is what counts in javascript.
Beverleyh
04-16-2014, 02:49 PM
Will do and thanks for the case insensitivity tip John :)
Jim Weinberg
04-16-2014, 03:07 PM
Okay, guys. Now I'm thoroughly confused.
John - PHP is enabled on the server, I use PHP routines on other pages and they work fine. I'm not sure where you found index.php, it's not a file that I use in this application.
Beverley - I haven't tried the code that you listed. I will, and let you know.
Nothing I've read explains why, if I define it as an .html page, the page displays properly, but the slideshow doesn't work. However, if I define it as a .php page, nothing works.
As to the coding, I'm simply copying the code that Beverley sent me. I think Beverley is right in that it has something to do with the addressing. I'm still trying to work on that.
Jim Weinberg
04-16-2014, 05:32 PM
Okay, guys. I finally got a hold of the server tech support. Beverley, you were right. The server path was VERY different. I've modified the code to use the new server paths and it works ... sort of. What happens now is that the webpage displays, but it shows the list of files in ShopPics instead of sending the array to the fadeslideshow script. Here's what the code looks like now, so we're all on the same page, so to speak:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<?php include('/hsphere/local/home/bswebmas/ohiobuttons.org/test/Script_Files/build_array.php');?>
<script type="text/javascript" src="Script_Files/fadeslideshow.js">
/***********************************************
* Ultimate Fade In Slideshow v2.0- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>
<script>
var ShowPics=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [400, 300], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
</script>
<?php imageSlideArray('/hsphere/local/home/bswebmas/ohiobuttons.org/test/Graphics/ShowPics/', '/test/Graphics/ShowPics/');?>
<script>
],
displaymode: {type:'auto', pause:2000, cycles:1, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "none",
togglerid: ""
})
</script>
</head>
<body bgcolor="#FEF4E4">
<center>
<table cellspacing=1 border=0 width=100%>
<tr>
<td colspan=3 valign="top" align="center"><font size="4" color="Navy"><b>The Buckeye State Button Society<br>presents</b></td></tr>
<tr>
<td align="center" valign="middle"><p><font size="6" color="Green" face="Arial"><center>Spring Show 2014</font>
<p><font size=4 color="Navy"><b>April 9-10, 2015</b></font></td>
</tr><tr>
<td align="center">
<table border=0>
<td align="center" valign="top">
<div id="fadeshow1"></div>
</td>
</tr></table>
</tr></table>
</center>
</body>
</html>
Here's what the page display looks like: 5429
I feel like we're really close to getting this solved. I really want to thank both of you for all your help. Any thoughts on the next step would be greatly appreciated.
Beverleyh
04-16-2014, 06:47 PM
If you have a look at my previous posts, you'll see that the script tags do not close and then open again around the php function call.
jscheuer1
04-16-2014, 07:30 PM
Also, in the function that makes the array you have to change <br> to \n (see my previous post)
Jim Weinberg
04-16-2014, 09:20 PM
Beverley - I didn't think that they should go there, but if I take out the tags, I just get the html code executed. I don't even get the file list.
John - Thanks for the reminder. With everything else, I just overlooked that.
I've changed the code (taken out the script tags and replace the <br> tag).
jscheuer1
04-17-2014, 02:30 AM
I see no change. Here's the view source:
<script>
var ShowPics=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [400, 300], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
</script>
["/test/Graphics/ShowPics/100_0466-A.jpg"],<br/>["/test/Graphics/ShowPics/100_0467-A.jpg"],<br/>["/test/Graphics/ShowPics/100_0469-A.jpg"],<br/>["/test/Graphics/ShowPics/100_0470-A.jpg"],<br/>["/test/Graphics/ShowPics/100_0471-A.jpg"],<br/>["/test/Graphics/ShowPics/100_0472-A.jpg"]<br/>
<script>
],
displaymode: {type:'auto', pause:2000, cycles:1, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "none",
togglerid: ""
})
</script>
The highlighted tags must be removed and in Bev's function:
echo "[\"$path$files_array[$i]\"]$comma<br>";
Needs to be:
echo "[\"$path$files_array[$i]\"]$comma\n";
Jim Weinberg
04-17-2014, 01:07 PM
John.
Not sure which file you were looking at. The NewFadinSlideshow_1 file does not have the script tags. However, I did notice a typo in the array definition. I corrected that and everything works.
John & Beverley.
Thank you both so much for all your help and patience. I know this was frustrating ... for all of us. Now all I have to do is transfer everything to the real page, which I don't foresee any problems with. Again, many thanks for your help.
Mark this puppy RESOLVED.
Best regards to you both.
Jim
jscheuer1
04-17-2014, 02:19 PM
Great! I was looking before at NewFadinSlideShow.php. The newer file looks fine. BTW, way back when I mentioned index PHP, I meant the (at that time) single PHP file in the test folder. It did have (among others) the word index in its name, but was not displaying. You've since fixed that somehow, in any case that file is no longer there in the folder view.
Jim Weinberg
04-18-2014, 04:32 PM
John & Beverley.
I hope your still monitoring this post. Everything works fine, but what I'd like to do is to move the slideshow definitions
i.e.
var ShowPics=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [650, 490], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
<?php imageSlideArray('/hsphere/local/home/bswebmas/ohiobuttons.org/Graphics/ShowPics/CurrentShow/', '/Graphics/ShowPics/CurrentShow/');?>
],
displaymode: {type:'auto', pause:2000, cycles:1, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "none",
oninit: function(){++this.setting.currentstep},
onslide: function(){
if(this.setting.currentstep === this.setting.imagearray.length){
setTimeout(ShowPics1, this.setting.displaymode.pause);
}
},
togglerid: ""
})
var ShowPics1 = function(){
Showpics=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [560, 490], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
<?php imageSlideArray('/hsphere/local/home/bswebmas/ohiobuttons.org/Graphics/ShowPics/PreviousShows/', '/Graphics/ShowPics/PreviousShows/');?>
],
displaymode: {type:'auto', pause:2000, cycles:1, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "ondemand",
togglerid: ""
});
}
to an external file.
I believe it needs to be a .php file, but I'm not sure what the syntax should be. Also, can I just reference it as I would a .js file i.e.
<script type="text/javascript" src="Script_Files/slidedef.php">) or would I use an include as I did for the build_array routine?
I'd appreciate any recommendation you would have.
Thanks.
p.s. If this should be posted as a new thread, let me know and I'll do it.
jscheuer1
04-18-2014, 04:52 PM
Yes. do it like that:
<script type="text/javascript" src="Script_Files/slidedef.php">
But include a PHP javascript header at the beginning of the external file:
<?php
header("content-type: application/x-javascript");
?>
Any relative paths used by javascript in the file should be relative to the page that's using it. Relative paths used by PHP should be relative to the file itself. Looks like all that's OK at the moment (the relative paths).
Jim Weinberg
04-18-2014, 08:29 PM
Hi John.
Didn't work. To make sure I didn't mess something up, here's the new code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<?php include('/hsphere/local/home/bswebmas/ohiobuttons.org/test/Script_Files/build_array.php');?>
<script type="text/javascript" src="Script_Files/fadeslideshow.js">
/***********************************************
* Ultimate Fade In Slideshow v2.0- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>
<script type="text/javascript" src="Script_Files/slidedef.php">
</head>
<body bgcolor="#FEF4E4">
<center>
<table cellspacing=1 border=0 width=100%>
<tr>
<td colspan=3 valign="top" align="center"><font size="4" color="Navy"><b>The Buckeye State Button Society<br>presents</b></td></tr>
<tr>
<td align="center" valign="middle"><p><font size="6" color="Green" face="Arial"><center>Spring Show 2014</font>
<p><font size=4 color="Navy"><b>April 9-10, 2011</b></font></td>
</tr><tr>
<td align="center">
<table border=0>
<td align="center" valign="top">
<div id="fadeshow1"></div>
</td>
</tr></table>
</tr></table>
</center>
</body>
</html>
The external file (located in /Script_Files, the same folder as fadeslideshow.js) is:
<?php
header("content-type: application/x-javascript");
?>
var ShowPics=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [650, 490], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
<?php imageSlideArray('/hsphere/local/home/bswebmas/ohiobuttons.org/Graphics/ShowPics/CurrentShow/', '/Graphics/ShowPics/CurrentShow/');?>
],
displaymode: {type:'auto', pause:2000, cycles:1, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "none",
oninit: function(){++this.setting.currentstep},
onslide: function(){
if(this.setting.currentstep === this.setting.imagearray.length){
setTimeout(ShowPics1, this.setting.displaymode.pause);
}
},
togglerid: ""
})
var ShowPics1 = function(){
Showpics=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [560, 490], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
<?php imageSlideArray('/hsphere/local/home/bswebmas/ohiobuttons.org/Graphics/ShowPics/PreviousShows/', '/Graphics/ShowPics/PreviousShows/');?>
],
displaymode: {type:'auto', pause:2000, cycles:1, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "ondemand",
togglerid: ""
});
}
jscheuer1
04-19-2014, 02:15 AM
There are at least two problems here. I hope that's it. For one, you need a closing script tag here (added in red):
<script type="text/javascript" src="Script_Files/fadeslideshow.js">
/***********************************************
* Ultimate Fade In Slideshow v2.0- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>
<script type="text/javascript" src="Script_Files/slidedef.php"></script>
</head>
For the other, instead of including the external file with the PHP function on it here:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<?php include('/hsphere/local/home/bswebmas/ohiobuttons.org/test/Script_Files/build_array.php');?>
<script type="text/javascript" src="Script_Files/fadeslideshow.js">
It should be included on slidedef.php like so:
<?php
header("content-type: application/x-javascript");
include 'build_array.php';
?>
var ShowPics=new fadeSlideShow({
wrapperid: "fadeshow1", //I . . .
You can probably use the server path there if you like. But, since it's in the same folder, just that should be OK.
Assuming everything else is good, that should do it.
Jim Weinberg
04-19-2014, 11:10 AM
Hi John.
Sorry about the end tag. The good news is that it works! ;) Thanks. BTW, I didn't need the server path in the build_array address.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.