PDA

View Full Version : photo gallery help, please!


madHatter
05-14-2003, 08:53 PM
Hello

I have a simple image gallery (5 small photos in total). If the visitor clicks the next link, he is redirected to the next photo, etc.

The photos are actually photos taken of web sites, and while I wouldn't want the actual photos to be a link to the web site they belong to, I would like a link under the photo, so that when clicked, it would take the vicitor to that photo's respective web site.

Would I just normal HTML for that?

I am copying and pasting the code here to give an idea of how the gallery functions.

Thanks for any suggestions.

madHatter


<%Option Explicit%>
<%Response.Buffer = "True"%>

<HTML>
<HEAD>
<TITLE>portfolio</TITLE>
</HEAD>
<BODY>

<%


'Dim all the variables required here
Dim objFSO 'Creates an instance of the file system object
Dim objFolder 'Gets the current folder
Dim objFile 'Gets the current file
Dim Path 'Stored images
Dim Series 'Pix location
Dim ImageCount 'No of images
Dim ImageNumber 'Number of image displayed
Dim NextImage 'Next image link
Dim PreviousImage 'Previous image link
Dim FileExtention 'Grabs the file extention (".jpg")
Dim ErrorPage 'In the case of error

'Set the counter to zero
ImageCount = 0

ErrorPage = "index1.asp?GalleryError=True"

Set Path = Request.QueryString("Path")
Set Series = Request.QueryString("Series")
If Path = "" OR Series = "" Then
Response.Redirect(ErrorPage)
End If

If ImageCount = 0 Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath(Path & "/" & Series))
For Each objFile In objFolder.Files
FileExtention = LCase(Right((objFile.Name), 4))
If FileExtention = ".jpg" Then
ImageCount = Cint(ImageCount) + 1
End If
Next

'Destroy the objects
Set objFSO = Nothing
Set objFolder = Nothing
Set objFile = Nothing
End If

ImageNumber = Cint(Request.QueryString("ImageNumber"))
If ImageNumber < 1 Then
ImageNumber = 1
ElseIf ImageNumber > ImageCount Then
ImageNumber = ImageCount
End If

'This function generates the "previous" & "next" buttons
Function Buttons(ImageCount, ImageNumber)
If ImageNumber = 1 Then
NextImage = "<A HREF=""gallery1.asp?Path=" & Path & "&Series=" & Series & "&ImageNumber=" & (ImageNumber + 1) & """>next</A>"
PreviousImage = "previous"
ElseIf ImageNumber > 1 AND ImageNumber < ImageCount Then
NextImage = "<A HREF=""gallery1.asp?Path=" & Path & "&Series=" & Series & "&ImageNumber=" & (ImageNumber + 1) & """>next</A>"
PreviousImage = "<A HREF=""gallery1.asp?Path=" & Path & "&Series=" & Series & "&ImageNumber=" & (ImageNumber - 1) & """>previous</A>"
Else
NextImage = "next"
PreviousImage = "<A HREF=""gallery1.asp?Path=" & Path & "&Series=" & Series & "&ImageNumber=" & (ImageNumber - 1) & """>previous</A>"
End If
Buttons = PreviousImage & " | " & NextImage
End Function
%>

<TABLE WIDTH="300">
<TR>
<TD WIDTH="300" ALIGN="Right">
<%
'Displays the current image number, and total number of images
Response.Write("<H1>Image " & ImageNumber & " of " & ImageCount & "</H1><BR>")
%>
</TD>
</TR>
<TR>
<TD WIDTH="300" ALIGN="Right">
<%
Response.Write("<IMG SRC=""" & Path & "/" & Series & "/" & Series & "_" & ImageNumber & ".jpg" & """>")
%>
</TD>
</TR>
<TR>
<TD WIDTH="300" ALIGN="Right">
<%=Buttons(ImageCount, ImageNumber)%>
</TD>
</TR>

</TABLE>

</BODY>
</HTML>

raf
05-15-2003, 06:24 PM
I'm sorry but i don't get that.

What exactly are you trying to do? Where are rhe url and images stored? Are you planning on sticking with theese five images, or do you need something more dynamic?

madHatter
05-15-2003, 09:31 PM
Hello Raf

Thank you for your reply.

For the moment I am planning on these 5 images only.

You can see the code at work here: www.grafik1.net and then by clicking on portfolio.

At the moment I only have 'Previous' and 'Next' links under each of the 5 photos.

What I don't have is any description of what the photos are or any link from the photo(s) to a Web site (which is what I would like). I don't really want to make the photo itself a link, so I was thinking about a different link under each photo which the visitor could click on to be taken to the site where I got the photo from.

Thanks

Hatter

raf
05-15-2003, 09:59 PM
OK. I see.
Now i usually make database driven webapps and store as much as possible in the db. I don't know if you use a db for this site.
Suppose you have one.
Then create a table with
refID|refimage|refdescr|refurl

refID is an (auto)number 1--> 5 now
refimage is the adress (from the asp files directory) to the image)
refdescr is the description
refurl is the url your link need to pint to

On your page, you select the first record. You build the html to display image and link and description. The next/previous is only displayed if relevant + hold the value refID+1 or refID-1 in it's querystring. If these links or hit, the page is reloaded and another record is selected. If the querystring doesn't contain a value, refID=1 is selected.

Now, you could als do this without a db and use the FSO to build an imagelist + have the descriptions and url's in an XML file. It's slightly more complicated. Since you have a 'contact me' function, i assume you'de be using or would be better of by using a db.

Just let us know if you need more info.

(Like that style:thumbsup: but personally, i would have
- let the titlebar run further and have it run above my girlfriends picture and let it fade to white at the left
- have the vprevious and next at the top of the picture, so the link comes right under it and the description under that

madHatter
06-30-2003, 10:36 PM
Hello

Still trying to work out what you're saying, but no, I'm not using a database - I only have 5 images. This might grow, but perhaps to no more than, maybe 8.

Cheers

Hatter

ReyN
07-01-2003, 03:31 AM
hello

i have here a working example of how you can move thru the rows of a recordset ( in classic ASP ).

http://aspalliance.com/aspxtreme/ado/navigatingandpagingthrurecordset.aspx

while the sample uses a db, and may be more than what you need, just thought to post the link anyway just in case you or anyone else may have some need for such in the future.

and for anyone who needs a similar example in ASP.NET, here's one for you.

http://aspalliance.com//aspxtreme/sys/data/demos/datatablerows.aspx

:)

madHatter
07-01-2003, 08:53 PM
Hello reyN

Very many thanks for your reply and the invaluable link.

I've already visited the page and downloaded it. It looks heavy enough for me, but also something for me to get my teeth into!

Thanks again

Hatter