View Full Version : Help with PHP Photo Albumn Script - using file names

03-31-2006, 03:29 AM
This script is great, but I need some help with a small modification:


I need to be able to display the image file name minus the extention. It could be displayed in the "page1 page2 etc..." area or the "description" area.

There was an earlier post about this very thing, but it didn't work:


If someone could help me with a new modification or fix the one in the previous post, I would be very gratefull...

03-31-2006, 04:23 AM
Find this line in the script in step 3 on the demo page:

tempcontainer+=(descriptionprefix[0]==1)? descriptionprefix[1]+(i+1) : ""

Change it to:

tempcontainer+=galleryarray[i][0].replace(/\..*$/, '')

That's all you need, I have no idea what all that other stuff was that ddadmin was suggesting (I didn't wade through it). He was probably trying to make it easily reversible via the configuration.

03-31-2006, 04:45 AM
Well, I tried it, but it's still not working. Here's a look at my code. Am I doing something wrong?

<script src="http://www.todayspixel.com/billing/weaver/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="3x2" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
var imagepath="http://www.mysite.com/gallery/" //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=[1, "width=500px, height=400px, scrollbars, resizable"]

//Toggle image description: descriptionprefix[0 or 1, "Text to show" (if 1)]
var descriptionprefix=[1, "Photo "]

//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.todayspixel.com/billing/weaver/pdf/"

/////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")

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+'.pdf" target="'+href_target+'" onClick="return popuplinkfunc(this)">'
tempcontainer+='<img src="'+imagepath+galleryarray[i][0]+'" title="" galleryimg="no" />'
tempcontainer+='</a><br />'
tempcontainer+=galleryarray[i][0].replace(/\..*$/, '')
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) : ""

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>')
document.write('<br style="clear: left" />')

function popuplinkfunc(imgsrc){
if (popupsetting[0]==1){
var popwin=open(imgsrc.href, "popwin", popupsetting[1])
return false
return true


<!--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+')\">Invoice '+i+'</a> ')

03-31-2006, 05:18 AM
"Not working" is a little vague. As much of your code as you posted looks fine. Does it do anything? Do the images display? Do the links work? Can you supply a link to your page?

03-31-2006, 05:20 AM
I get nothing! Take a look: www.todayspixel.com/billing

03-31-2006, 05:27 AM
These are the errors reported in FF:

Error: galleryarray is not defined
Source File: http://www.todayspixel.com/billing/
Line: 152

Error: galleryarray is not defined
Source File: http://www.todayspixel.com/billing/
Line: 100

Error: missing ; before statement
Source File: http://www.todayspixel.com/billing/weaver/getpics.php
Line: 5, Column: 9
Source Code:
<b>Fatal error</b>: Call to undefined function: filename() in <b>/home/todayspi/public_html/billing/weaver/getpics.php</b> on line <b>13</b><br />

I doubt that changing that little bit of code as I suggested caused that. Was it working before you made the one modification I suggested in this thread? Did it ever work?

03-31-2006, 05:52 AM
Ok, got it! I had moved the page to a different directory to show you and didn't change the links in the code. DOHH!

Thank you very much...