# HTML slideshow?



## Peacock (Oct 9, 2003)

I'd like to do a "slideshow" of HTML files - I have about 90 HTML docs and would like the user to be able to click "previous" and "next" links at the bottom of the page to navigate through the information. How would you recommend I do this? Can I do it with PHP? Can you recommend any snippets of code?

Thanks,
Lisa


----------



## khaki (Jul 26, 2003)

hi Lisa....

you could probably do something like that using 's.

are you looking to do this specifically using PHP?
(if so.... I can't help you..... I'm an ASP girl  )

And actually... a server-side solution would probably hammer the server too hard (cuz you have a _lot_ of pages  )....
so maybe a client-side solution using javascript and 's is best.

I may have something already coded that does that. I'll look for it later tonite and see if it fits what you are trying to do.

stay tuned.......

 khaki


----------



## Peacock (Oct 9, 2003)

I can't use frames; I want to make it 508 compliant. 

So far, I have...
- a text file which lists the file name of each slide and a "page number" for each slide (/slide001.htm;1;/slide002.htm;2;etc)
- a template
- 90 pages based on said template

I'd like to have the forward button take a look at the number of the page that is currently up, add one to the page number, and pull the corresponding HTML file. And for the reverse, subtract one and pull the corresponding HTML file.


----------



## khaki (Jul 26, 2003)

your a demanding one, Lisa  .....

but okay.....

I only know ASP (and not PHP)..... so that's all that I can comment on.

But....
depending upon the content....
you can do this server-side..... although that would force the user to re-read the menu (and everything else) after each page load, right???
(so I'm not sure how 508 compliant _that_ is).

But anyway... 
you could use client-side OnClick events to query a DB that contains text data.....
and have that data populate a table (  is that compliant???) or a (  ) based on the results of an SQL query.

Does _this_ sound like something that would work for you???

Like I said.... I'm an ASP girl....
so I can only provide an ASP example.
If you are able to convert it to a PHP solution... then good for you 

Otherwise...... sorry  (but I tried)

Let me know

 khaki


----------



## Gibble (Oct 10, 2001)

K, just give asp code, and I'll give it the old switcharoo


----------



## brendandonhu (Jul 8, 2002)

A simple PHP script should be able to do this. Later I'll write something for you. It will take each HTML file in a directory, give it an ID number, and have Back and Forward buttons for navigation, that sound good?


----------



## bassetman (Jun 7, 2001)

B where ya been lately?


----------



## brendandonhu (Jul 8, 2002)

Heres the start of the script (with the important parts *Borrowed* from onjae.com)

I will do the Navigation and error correction when I get home...


```
<?php 
$dir = opendir('.'); 
$files[] = $PHP_SELF;
while (($file = readdir($dir)) !== false) { 
$files[] = $file;
}
closedir($dir);
if(isset($_GET['page']))
{
include($files[$_GET['page']]);
 ;}
?>
```


----------



## Peacock (Oct 9, 2003)

I'll try that code and see how it works. Thank you all!

Yes, I am demanding. In fact, I have anothe question!

I have a dreamweaver template (.dwt) which has a bit of php at the top:

<?php
inlcude 'header.php'
?>

Now, should all files based on that template be saved as HTML or as PHP files? Thanks in advance - I'm new to PHP.

L


----------



## Gibble (Oct 10, 2001)

if it has php code (stuff between <? and ?>) then save it as php, otherwise save it as html.

Both are text, so it's merely the extension that determines how the webserver handles the file.

But in the case of this template, they are probably all php files.


----------



## AbvAvgUser (Oct 3, 2002)

If your HTML files contain Images and its a slide show of images, try out JAlbum (http://www.datadosen.se/jalbum). It will make a slide show with a few clicks and very efficiently. Its a freeware .


----------



## brendandonhu (Jul 8, 2002)

Heres the script I came up with...


```
<?php
$dir = opendir('.'); 
$files[] = $PHP_SELF;
while (($file = readdir($dir)) !== false) { 
$files[] = $file;
}
closedir($dir);
$first = 1;
$last = count($files) - 1;
$forward = $_GET['page'] + 1;
$back = $_GET['page'] - 1;
if(isset($_GET['page']))
{
include($files[$_GET['page']]);
 ;}
?>

[URL=<?php echo $PHP_SELF .]">First Page[/URL]|[URL=<?php echo $PHP_SELF .]">Back[/URL]|[URL=<?php echo $PHP_SELF .]">Forward[/URL]|[URL=<?php echo $PHP_SELF .]">Last Page[/URL]
```


----------



## khaki (Jul 26, 2003)

okay Gibby.....
now that Brendan gave us the PHP version (also know as complete gibberish  )....

how about you "give it the old switcharoo" into ASP for me 
(or at least explain what each line means  _p-l--e-a-s-e_  )

all these stinkin' question-marks and dollar-signs are maddening !


----------



## Gibble (Oct 10, 2001)

> _Originally posted by khaki:_
> *okay Gibby.....
> now that Brendan gave us the PHP version (also know as complete gibberish  )....
> 
> ...




```
<%
Set objFS = Server.CreateObject("Scripting.FileSystemObject")
FolderPath = Request.ServerVariables("APPL_PHYSICAL_PATH")
Set objFolder = objFS.GetFolder(FolderPath)
Set objFiles = objFolder.Files

iFirst = 1
iLast = objFiles.Count

iForward = Request.QueryString("page") + 1; 
iBack = Request.QueryString("page") - 1; 
if (Request.QueryString("page") > 0) then
	'This isn't proper asp because includes in ASP don't allow variable strings like this...
	%>
	<!-- #include file=objFiles[Request.QueryString("page")] -->
	%>
end if
%> 

<hr> 
<a href="<%Response.write Request.ServerVariables("SCRIPT_NAME ") & "?page=" . iFirst %>">First Page</a>
|
<a href="<%Response.write Request.ServerVariables("SCRIPT_NAME ") & "?page=" . iBack %>">Back</a>
|
<a href="<%Response.write Request.ServerVariables("SCRIPT_NAME ") & "?page=" . iForward %>">Forward</a>
|
<a href="<%Response.write Request.ServerVariables("SCRIPT_NAME ") & "?page=" . iLast %>">Last Page</a>
```
It may not be 100%, and the include needs to be worked differently with a document reader function...but that's basically the way it would be coded in ASP.


----------



## brendandonhu (Jul 8, 2002)

> _Originally posted by khaki:_
> *
> all these stinkin' question-marks and dollar-signs are maddening !   *


$ = variable

I suppose I could cut it down to 2 ?s but that wouldnt be fun..


----------



## bassetman (Jun 7, 2001)

Sooo B, you just create a seperate Dir, put the HTML files you want to use in that same Dir and it takes care of everything else?


----------



## brendandonhu (Jul 8, 2002)

Yup, more or less. Of course, you'll want to make some sort of menu or layout or something. I just made links as examples of Next, Back, etc.


----------



## bassetman (Jun 7, 2001)

So how does someone interface the Php into an HTML doc?
Make the HTML and insert the php or the other way around? 

I am pretty naive about php.


----------



## brendandonhu (Jul 8, 2002)

My script would go in a PHP file. You can put regular HTML in a PHP file, just make sure its not between <? and ?> tags. See how I put HTML at the end of my script?


----------



## bassetman (Jun 7, 2001)

So something like


```
<?php 
$dir = opendir('.');  
$files[] = $PHP_SELF; 
while (($file = readdir($dir)) !== false) {  
$files[] = $file; 
} 
closedir($dir); 
$first = 1; 
$last = count($files) - 1; 
$forward = $_GET['page'] + 1; 
$back = $_GET['page'] - 1; 
if(isset($_GET['page'])) 
{ 
include($files[$_GET['page']]); 
 ;} 
?>

[URL=<?php echo $PHP_SELF .]">First Page[/URL]|[URL=<?php echo $PHP_SELF .]">Back[/URL]|[URL=<?php echo $PHP_SELF .]">Forward[/URL]|[URL=<?php echo $PHP_SELF .]">Last Page[/URL]
```
????


----------



## Gibble (Oct 10, 2001)

yes, exactly like that, and save it as whatever.php


----------



## bassetman (Jun 7, 2001)

Thanks to both of you!!!


----------



## bassetman (Jun 7, 2001)

I'm getting an error and sent B the URL to check it out for me


----------



## bassetman (Jun 7, 2001)

BTW B this is line 17 where the other error is coming from


> include($files[$_GET['page']]);


Are there too many "]"'s there?

Just my limited knowledge!


----------



## brendandonhu (Jul 8, 2002)

Nope, that line is correct. Notice there are 2 [s and 2 ]s.

BTW everyone-we are discussing the problems via PM right now.


----------



## Gibble (Oct 10, 2001)

before the include line put 
echo 'Include:' . $files[$_GET['page']]; 
and make sure that the path is correct


----------



## brendandonhu (Jul 8, 2002)

There are some bugs to be fixed, such as not allowing negative page numbers, and not attempting to include directories.


----------



## bassetman (Jun 7, 2001)

Hey B! Had any time to look at this again?


----------



## rocknchic (Oct 21, 2002)

Hey, has anyone mentioned recently that Brendandonhu happens to be freaking amazing? Tell me Brendan, are you really 50 and making 150,000 a year?


----------



## bassetman (Jun 7, 2001)

He's no where near 50!


----------



## Peacock (Oct 9, 2003)

Thank you!


----------



## bassetman (Jun 7, 2001)

Peacock, please note that I have tried running the script and it seems to have some bugs in it yet.


----------



## pyritechips (Jun 3, 2002)

If you're lazy you can try some of these copy/paste slideshows:

http://www.dynamicdrive.com/dynamicindex14/index.html


----------



## bassetman (Jun 7, 2001)

I'll look into it!


----------

