Published: Wednesday, October 25, 2000
A Picture Gallery using the Content Linking Component, Part 2
By Evagoras Charalambous
Read Part 1
In Part 1 we looked at the first of six files in our Picture Gallery
application - common.asp. In this part we'll continue our examination of the other ASP files
that make up the Picture Gallery!
default.asp
Our starting page, when visited through a browser, lists the various folders of pictures (or each gallery), the total file size
for each folder, the number of pictures in the folder, a link to an Administration page, and an option to view
a slide show. A screenshot of default.asp can be seen below:
The code goes through the myFolder you specified in common.asp (pictures
in this case) and looks for folders. For every folder it finds it checks to see if it contains a text
Content Linking file with the name we specified in myTextFile (i.e. ContLink.txt). If
there is none, it loops through all the contents of the folder, creates a string with the names of the files,
and then uses the FileSystemObject to write it in its folder. At this moment the "Description" is just the
name of the file without the extension. After that, or if the text file is already there, it creates the
table as shown above. Using the pulldown menu for each folder you can choose a time to automatically loop through
that folder. You may choose to remove the link to the administration page from this page if others will have
access here.
list.asp
By clicking on the folder name school in the default.asp page you get the screen
below:
This page simply lists all the "Titles" of the pictures in the specific folder, which is harvested from the
"Description" of the picture in its text file. From here you can click on a specific picture to view it.
show.asp
This file displays the pictures. Format the page to how you see fit. I added some code on top to show you
where you are in relation to the total pictures in the folder, and links to the Next/Previous pictures.
Since we may have a slew of pictures in a given folder (gallery), we must know what picture we are currently
viewing out of the list of total pictures. This position is specified and maintained by a variable named
Index that we pass through the QueryString.
If we get to this page by
selecting the "slide show" from the default.asp page then it will refresh after the number of
seconds we specified, fetching the next picture in our gallery. After the last picture it goes back to our
list of pictures for that folder.
admin.asp + do_admin.asp
The administration page allows us to delete and edit pictures. We can easily add a Title and Description to our
pictures. The pictures are the same ones as the larger ones, just at a smaller scale, so if you have a lot of
them in the folder it could take a while to load. I like to see them here because sometimes I choose to erase
some of them. To delete a picture from the folder and from its Content Linking file, click on the
corresponding "Delete" checkbox next to the picture. Once you are done with your changes, click the submit
button. The changes are carried over to the do_admin.asp page, which does all the processing.
Below is a screenshot of the administration page:
Last Thoughts
And now that you have your gallery ready and functioning, you can use it to post your summer vacation pictures
on your personal site, or for a much bigger project. This method works relatively easy and is not very hard on
the server. There is one drawback though that's pretty obvious. If you want to preserve your Titles and
Descriptions when you are adding new pictures you will have to edit the text file directly. One could possibly
work on that and add the functionality to this code. My code only checks for the
existence of a text linking file, and if one is already there it accepts it.
If you add/delete many pictures to your folders you might want to erase the
text file from that folder and reload the default.asp page to create a new
text file. You would then loose your Titles and Descriptions if you have
any. One could possibly work on this and add further functionality to my
code that would check the text linking files against the folder contents and
do the necessary updates.
If you have any suggestions for improving this code or questions on it, feel free to contact me.
I can be reached at my website at http://www.evagoras.com/ or at my email
evagoras@evagoras.com.
Happy Programming!
Attachments:
Download the pictures and source code in ZIP format
Try out the live demo!