HthrT
02-09-2007, 09:46 AM
1) Script Title: Lightbox image viewer 2.0 and PHP Photo Album script
2) Script URL (on DD): Lightbox V.2 (http://dynamicdrive.com/dynamicindex4/lightbox2/index.htm) and PHP Photo Album (http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm)
3) Describe problem:
I know this forum has dissected this combination in a number of posts, and I've gotten it to work, except that I can't figure out how to make the Lightbox script create href links with the PHP script.:confused:
I must be truly stupid because no one else seems to have a problem understanding this, namely:
Lightbox v2.0 uses the Prototype Framework and Scriptaculous Effects Library.
Step 2: Create your "thumbnail" image links, for example:
<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>
The rel attribute is mandatory in order to activate the effect for this particular image. The "title" attribute is optional, and when defined, adds a caption beneath the enlarged image. The "href" attribute obviously should contain the path to the enlarged image.
LightBox version 2 adds the ability to group multiple image links together, so an image gallery is created out of the enlarged images:
<a href="images/image-1.jpg" rel="lightbox[roadtrip]">image #1</a>
<a href="images/image-2.jpg" rel="lightbox[roadtrip]">image #2</a>
<a href="images/image-3.jpg" rel="lightbox[roadtrip]">image #3</a>
As you can see, to group image links together, simply modify the "rel" attribute to be "lightbox[roadtrip]" instead, where "roadtrip" is an arbitrary but unique name for that group. You can have multiple groups of images on the same page- just use a unique group name in each case. Grouped images can be cycled through by clicking on the right/left edges of each enlarged image.
I don't see how that applys to my PHP layout!? :confused: :confused:
So, although I get beautiful Lightbox effects enlargements I can not scroll through the Prev and Next options or add Captions, in fact the 'Prev' 'Nav' and Captions don't even appear (I guess because the script does't see any connections).:mad:
I've gotten the idea that this has something to do with the 'gallery array'
If someone could please show me how to make this connection I would be so glad to learn!
my code:
<!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>
<link href="ahaendel.css" rel="stylesheet" type="text/css" media="screen" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Anitra Haendel</title>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
-->
</style>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
</head>
<body>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><div id="imagearea"></div>
<script src="http://www.heathertroy.net/anitrahaendel/images/gallery/vincents/getpics.php" type="text/javascript"></script>
<script type="text/javascript">
/***********************************************
* PHP Photo Album script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/
var dimension="4x6" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
var imagepath="http://www.heathertroy.net/anitrahaendel/images/gallery/vincents/" //Absolute path to image directory. Include trailing slash (/)
var href_target="new" //Enter target attribute of links, if applicable
//Toggle popup link setting: popupsetting[0 or 1, "pop up window attributes" (if 1)]
var popupsetting=[0, "width=500px, height=400px, scrollbars, resizable"]
//Toggle image description: descriptionprefix[0 or 1, "Text to show" (if 1)]
var descriptionprefix=[0, ""]
//Sort images by date? ("asc", "desc", or "")
//"desc" for example causes the newest images to show up first in the gallery
//"" disables this feature, so images are sorted by file name (default)
var gsortorder="desc"
//By default, each image hyperlinks to itself.
//However, if you wish them to link to larger versions of themselves
//Specify the directory in which the larger images are located
//The file names of these large images should mirror those of the original
//Enter a blank string ("") to disable this option
var targetlinkdir="http://www.heathertroy.net/anitrahaendel/images/gallery/vincents/enlarged/"
/////No need to edit beyond here///////////////////
function sortbydate(a, b){ //Sort images function
if (gsortorder=="asc") //sort by file date: older to newer
return new Date(a[1])-new Date(b[1])
else if (gsortorder=="desc") //sort by file date: newer to older
return new Date(b[1])-new Date(a[1])
}
if (gsortorder=="asc" || gsortorder=="desc")
galleryarray.sort(sortbydate)
var totalslots=dimension.split("x")[0]*dimension.split("x")[1]
function buildimage(i){
var imagecompletepath=(targetlinkdir!="")? targetlinkdir+galleryarray[i][0] : imagepath+galleryarray[i][0]
var tempcontainer='<a href="'+imagecompletepath+'" rel="lightbox">'
tempcontainer+='<img src="'+imagepath+galleryarray[i][0]+'" title="'+galleryarray[i][0]+' ['+galleryarray[i][1]+']" />'
tempcontainer+='</a><br />'
tempcontainer+=(descriptionprefix[0]==1)? descriptionprefix[1]+(i+1) : ""
return tempcontainer
}
function jumptopage(p){
var startpoint=(p-1)*totalslots
var y=1;
for (i=0; i<totalslots; i++){
document.getElementById("slide"+i).innerHTML=(typeof galleryarray[startpoint+i]!="undefined")? buildimage(startpoint+i) : ""
}
while(document.getElementById("navlink"+y)!=null){
document.getElementById("navlink"+y).className=""
y++
}
document.getElementById("navlink"+p).className="current"
initLightbox();
}
var curimage=0
for (y=0; y<dimension.split("x")[1]; y++){
for (x=0; x<dimension.split("x")[0]; x++){
if (curimage<galleryarray.length)
document.write('<div id="slide'+curimage+'" class="slideshow">'+buildimage(curimage)+'</div>')
curimage++
}
document.write('<br style="clear: left" />')
}
function popuplinkfunc(imgsrc){
document.getElementById("imagearea").innerHTML='<img src="'+imgsrc+'"/>'
return false
}
</script>
<!--Below HTML code refers to the navigational links for the gallery-->
<div id="navlinks">
<script type="text/javascript">
for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++)
document.write('<a id="navlink'+i+'" href="javascript:jumptopage('+i+')\"></a> ')
document.getElementById("navlink1").className="current"
</script>
</div></td>
</tr>
</table>
</body>
</html>
PLEASE HELP, it's so nice of everyone to share their collective wisdom for those of us still learning. I hope I've made my problem clear.
Thanks in Advance, Heather
2) Script URL (on DD): Lightbox V.2 (http://dynamicdrive.com/dynamicindex4/lightbox2/index.htm) and PHP Photo Album (http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm)
3) Describe problem:
I know this forum has dissected this combination in a number of posts, and I've gotten it to work, except that I can't figure out how to make the Lightbox script create href links with the PHP script.:confused:
I must be truly stupid because no one else seems to have a problem understanding this, namely:
Lightbox v2.0 uses the Prototype Framework and Scriptaculous Effects Library.
Step 2: Create your "thumbnail" image links, for example:
<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>
The rel attribute is mandatory in order to activate the effect for this particular image. The "title" attribute is optional, and when defined, adds a caption beneath the enlarged image. The "href" attribute obviously should contain the path to the enlarged image.
LightBox version 2 adds the ability to group multiple image links together, so an image gallery is created out of the enlarged images:
<a href="images/image-1.jpg" rel="lightbox[roadtrip]">image #1</a>
<a href="images/image-2.jpg" rel="lightbox[roadtrip]">image #2</a>
<a href="images/image-3.jpg" rel="lightbox[roadtrip]">image #3</a>
As you can see, to group image links together, simply modify the "rel" attribute to be "lightbox[roadtrip]" instead, where "roadtrip" is an arbitrary but unique name for that group. You can have multiple groups of images on the same page- just use a unique group name in each case. Grouped images can be cycled through by clicking on the right/left edges of each enlarged image.
I don't see how that applys to my PHP layout!? :confused: :confused:
So, although I get beautiful Lightbox effects enlargements I can not scroll through the Prev and Next options or add Captions, in fact the 'Prev' 'Nav' and Captions don't even appear (I guess because the script does't see any connections).:mad:
I've gotten the idea that this has something to do with the 'gallery array'
If someone could please show me how to make this connection I would be so glad to learn!
my code:
<!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>
<link href="ahaendel.css" rel="stylesheet" type="text/css" media="screen" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Anitra Haendel</title>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
-->
</style>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
</head>
<body>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><div id="imagearea"></div>
<script src="http://www.heathertroy.net/anitrahaendel/images/gallery/vincents/getpics.php" type="text/javascript"></script>
<script type="text/javascript">
/***********************************************
* PHP Photo Album script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/
var dimension="4x6" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
var imagepath="http://www.heathertroy.net/anitrahaendel/images/gallery/vincents/" //Absolute path to image directory. Include trailing slash (/)
var href_target="new" //Enter target attribute of links, if applicable
//Toggle popup link setting: popupsetting[0 or 1, "pop up window attributes" (if 1)]
var popupsetting=[0, "width=500px, height=400px, scrollbars, resizable"]
//Toggle image description: descriptionprefix[0 or 1, "Text to show" (if 1)]
var descriptionprefix=[0, ""]
//Sort images by date? ("asc", "desc", or "")
//"desc" for example causes the newest images to show up first in the gallery
//"" disables this feature, so images are sorted by file name (default)
var gsortorder="desc"
//By default, each image hyperlinks to itself.
//However, if you wish them to link to larger versions of themselves
//Specify the directory in which the larger images are located
//The file names of these large images should mirror those of the original
//Enter a blank string ("") to disable this option
var targetlinkdir="http://www.heathertroy.net/anitrahaendel/images/gallery/vincents/enlarged/"
/////No need to edit beyond here///////////////////
function sortbydate(a, b){ //Sort images function
if (gsortorder=="asc") //sort by file date: older to newer
return new Date(a[1])-new Date(b[1])
else if (gsortorder=="desc") //sort by file date: newer to older
return new Date(b[1])-new Date(a[1])
}
if (gsortorder=="asc" || gsortorder=="desc")
galleryarray.sort(sortbydate)
var totalslots=dimension.split("x")[0]*dimension.split("x")[1]
function buildimage(i){
var imagecompletepath=(targetlinkdir!="")? targetlinkdir+galleryarray[i][0] : imagepath+galleryarray[i][0]
var tempcontainer='<a href="'+imagecompletepath+'" rel="lightbox">'
tempcontainer+='<img src="'+imagepath+galleryarray[i][0]+'" title="'+galleryarray[i][0]+' ['+galleryarray[i][1]+']" />'
tempcontainer+='</a><br />'
tempcontainer+=(descriptionprefix[0]==1)? descriptionprefix[1]+(i+1) : ""
return tempcontainer
}
function jumptopage(p){
var startpoint=(p-1)*totalslots
var y=1;
for (i=0; i<totalslots; i++){
document.getElementById("slide"+i).innerHTML=(typeof galleryarray[startpoint+i]!="undefined")? buildimage(startpoint+i) : ""
}
while(document.getElementById("navlink"+y)!=null){
document.getElementById("navlink"+y).className=""
y++
}
document.getElementById("navlink"+p).className="current"
initLightbox();
}
var curimage=0
for (y=0; y<dimension.split("x")[1]; y++){
for (x=0; x<dimension.split("x")[0]; x++){
if (curimage<galleryarray.length)
document.write('<div id="slide'+curimage+'" class="slideshow">'+buildimage(curimage)+'</div>')
curimage++
}
document.write('<br style="clear: left" />')
}
function popuplinkfunc(imgsrc){
document.getElementById("imagearea").innerHTML='<img src="'+imgsrc+'"/>'
return false
}
</script>
<!--Below HTML code refers to the navigational links for the gallery-->
<div id="navlinks">
<script type="text/javascript">
for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++)
document.write('<a id="navlink'+i+'" href="javascript:jumptopage('+i+')\"></a> ')
document.getElementById("navlink1").className="current"
</script>
</div></td>
</tr>
</table>
</body>
</html>
PLEASE HELP, it's so nice of everyone to share their collective wisdom for those of us still learning. I hope I've made my problem clear.
Thanks in Advance, Heather