Location: PHPKode > scripts > Snaps Album > snaps-album/example.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Example Album</title>
<?php require('SnapsAlbum.php'); ?>
<style>


#outerFrame {
	width: 980px;
}

.albumFrame {
	height: 200px;
	width: 200px;
	float: left;
	margin-bottom: 15px;
}

</style>
</head>

<body>
<?php 
// build array of album folders, so that all I have to do to add an album is upload the correct file structure with the photos in
$dir = 'photos/'; // directory that contains albums in folders.
$files = scandir($dir);
foreach ($files as $file) {
	if ($file!='.' && $file!='..' && is_dir($dir . $file))
	{
		if (count(glob($dir .$file.'/*.jp{g,eg}', GLOB_BRACE)) > 0){
			// Do not include any empty folders.
			$my_albums2[] = new SnapsAlbum($file, $dir); // create array of objects.
		}
	}
}

$alNum = 0;

if (!isset($_GET['album_num'])) { // if the uri variable album_num is not set show all the albums with a framed random thumbnail from it.?> 
<div id="outerFrame"> 
<?php 
	foreach ($my_albums2 as $album2) {
?>
	<div class="albumFrame">
    <div class="album"><a href="example.html?album_num=<?php echo $alNum ?>"><img src="photos/<?php echo $album2->get_snapsFolder() ?>/thumbnails/<?php echo $album2->snaps_getCover()?>" border="0" alt="<?php echo $album2->get_snapsTitle() ?>" /></a></div>
    <div class="titlePlaque"><span><a href="example.html?album_num=<?php echo $alNum ?>"><?php echo $album2->get_snapsTitle(); ?></a></span></div>
    </div>
<?php

		$alNum++;	
	}
?>
</div>
<?php 
} ?>
<?php if (isset($_GET['album_num'])) {  // if the uri variable album_num is set show the thumbnails of that album. ?>
<div id="snaps_images">
    <div id="nav">
        <ul>
            <li><a href="example.html">Home</a></li>
<?php
	foreach ($my_albums2 as $album2) {
	?>
				<li><a href="example.html?album_num=<?php echo $alNum ?>"><?php echo $album2->get_snapsTitle() ?></a></li>
	<?php
		$alNum++;
	}
?>
        </ul>
    </div>
<?php

	$currentAlbum = 0;
	if ($_GET['album_num']) {
		$currentAlbum = (int)$_GET['album_num'];
	}
	$currentPhoto = 0;
	$images_array = $my_albums2[$currentAlbum]->get_snaps_images(); // load this albums images.
	foreach ($images_array as $img => $imgArray) {
		$snaps_filename = $img;
		if (is_array($imgArray)) {
			
			if (!isset($_GET['photo_num'])) { // if the URI variable photo_num is not set show all the thumbnails of $my_albums2[$currentAlbum].
				echo ' <a href="example.html?album_num=' . $currentAlbum . '&amp;photo_num=' . $currentPhoto . '"><img src="' . $dir . $my_albums2[$currentAlbum]->get_snapsFolder() . '/thumbnails/' . $snaps_filename . '" alt="' . $snaps_filename . '" /></a> ';
			}
		}
		$currentPhoto++;
	}
	if (isset($_GET['photo_num'])) { // if the URI variable photo_num is set, only show the relevant photo full size.
		$currentPhoto = (int)$_GET['photo_num'];
		$curr_dimensions = $my_albums2[$currentAlbum]->get_snaps_photo_dimensions($currentPhoto);
		$curr_filename = $my_albums2[$currentAlbum]->get_snaps_photo_filename($currentPhoto);
		echo '<div><a href="example.html?album_num=' . $currentAlbum . '">Back to &#8220;' . $my_albums2[$currentAlbum]->get_snapsTitle() . '&#8221;</a></div>';
		echo '<img src="' . $dir . $my_albums2[$currentAlbum]->get_snapsFolder() . '/' . $curr_filename . '" ' . $curr_dimensions . ' alt="' . $curr_filename . '" /></a>';
	}
}
?>
</div>
</body>
</html>
Return current item: Snaps Album