Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Html pages pop-up 'on the fly' onclick.

Status
Not open for further replies.

BootBoy

Technical User
Apr 30, 2002
24
0
0
GB
I have an art gallery site with 100's of galleries of individual artist's work. Each artist's gallery has up to 100 thumbnails. I'm trying to find a script that will automatically create either pop-up pages 'on the fy' or even layers, containing (only) the larger version of the thumb, 'onclick'. I don't want to use 'Open browser window' or 'swap image' or show/hide layers alone as the work involved would be huge and the pages verbose.

If anyone has come across an efficient way of doing this I would be very grateful. Note: Each artist has their own folder with identical stucture ie. index.htm and 2 folders, 1 containing thumbs and 1 with 'big pics'. All images are named 1.jpg, 2.jpg, 3.jpg etc.

Thanks for your attention.

B [ponder]
 
try the java board.. by the way, what is the url?
 
You can do it with Perl, I've written a similar gallery script that reads the 'large-image' directory and populates the 'index.htm' with the thumbnails. The links used to be js pop-ups, but I changed the latest version to build pages for the large pic.

It could probably be changed back with a little work...er, scratch that - just found a backup copy of the old format. Feel free to pick it apart at your leisure:

Code:
#!/usr/bin/perl
#dynamic gallery cgi script
print "Content-type:text/html\n\n";

use CGI qw/:standard/;

$query = new CGI;
$curdir = $query->param('dir');

my $galdir = "[URL unfurl="true"]http://www.SITE.com/gallery";[/URL]
my $imgdir = "../gallery/$curdir";
my $thumbdir = "$curdir/thumbs";
my $count = 0;
my $i;

#reads the current directory and add images to array
opendir DIR, $imgdir or die "Could not open $imgdir directory: $!";
while ( $imgs = readdir DIR ) {
    next unless $imgs =~ /(\.jpg|\.jpeg|\.gif|\.mpe|\.mpeg|\.mov|\.rm|\.ram)$/i;
    push @imgs, $imgs;
}
closedir DIR;

#build table with thumbs and links to full images
print qq~<table width=&quot;800px&quot; align=&quot;left&quot; cellpadding=&quot;1&quot; cellspacing=&quot;1&quot; border=&quot;0&quot;><tr valign=&quot;top&quot;>\n\n~;

foreach ( sort @imgs ) {
    my ($name, $type) = split /\./;
    #thumbnails need to be named BIGIMAGE_thumb.xxx
    my $thumb = $name . '_thumb';
    print qq~<td align=&quot;left&quot;>\n~;

    print qq~<script>\n~;
    print qq~function popup$count(){\n~;
    print qq~var popurl=&quot;$galdir/$curdir/$name\.$type&quot;\n~;
    print qq~winpops=window.open(popurl,&quot;&quot;,&quot;top=0,left=0,scrollbars=1,resizable,&quot;)\n}\n~;
    print qq~</script>\n~;

    #next line switches file extension so script will also work with movie files
    $type = 'jpg' if $type =~ /(mpe|mpeg|mov|rm|ram)/i;
    print qq~<a href=&quot;javascript:popup$count()&quot;><img src=&quot;$galdir/$thumbdir/$thumb\.$type&quot; border=&quot;0&quot;></a>\n~;

    print qq~</td>\n\n~;
    $i++;
    $count++;
    if ($i == 7) {
        print qq~</tr><tr valign=&quot;top&quot;>\n\n~;
        $i = 0;
    }
}

print qq~</tr></table>~;

I placed the query string in an SSI tag in the .shtml file to call it, but I'm sure that could be worked around. Also, this hasn't been used in a while and I'm certain there's a reason I stopped using it...no guarantees [wink] Notorious P.I.G.
 
Thanks PIG, I'll give it a whirl and let you know, cheers.

B
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top