Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Multiple pictures

Quote Reply
Multiple pictures
I want to use multiple pictures in my database. Is there somebody already using this ?

I give an example : there is a big picture of the subject, for example a customed car.

Then, you have all the information on the right side of this picture. In this information I want to display thumbnails of this car. It is not immediatly needed that when they click on this little picture, that you see the original picture.

So is it possible that for some information you have no pictures extra, but it is possible that there are more pictures.

I think it must be possible using the relationships. Who can help me on my way to find this out ?
Luc
----
Quote Reply
Re: [LucVG] Multiple pictures In reply to
Hi Luc,

I've done something similar for one of my design clients, have a look at their site:

Willinghams


The first page is a list of all their vehicles - just click on one to see the thumbnails and pictures.


All the best
Shaun
Quote Reply
Re: [qango] Multiple pictures In reply to
yes shaun, that is exactly what I main.
Luc
----
Quote Reply
Re: [LucVG] Multiple pictures In reply to
Luc,

Okay, this is how I've done it for Willinghams - I hope you'll be able to make it work for your site too Smile

I don't know what your table is called so I'll use the term dbs for the code here, simply replace the instances of dbs with the name of your table.


BEFORE YOU START PLEASE, PLEASE MAKE A BACKUP OF ALL YOUR DATA AND TEMPLATES



IMAGE FIELDS: If you haven't already done so, create the required number of image fields in your table and create an equal number of thumbnail image fields too. Tip: To make it easy to manage these fields you might consider using the taxonomy (Photo_xx) for the photo fields and (Thumb_xx) for the thumbnails, where xx is a number.



NEW DETAILED TEMPLATE: To display the images and thumbnails we'll use a detailed record. Create a new template called record_dbs_detail.html and copy and paste the HTML from your current record_dbs.html into this new template.



DETAILED LINK: To display the detailed page we need a link to the search results using the new d=1 variable to denote the detailed page view and p=1 to say "display photo 1".

Edit your record_dbs.html template and add a link as follows (this can be over an existing part of the record or as a new separate link, its up to you):

Code:
<a href="db.cgi?db=dbs;do=search_results;d=1;ID=<%ID%>;p=1">Click for details</a>


or alternatively:

Code:
<a href="db.cgi?db=dbs;do=search_results;d=1;ID=<%ID%>;p=1"><%Field_Name%></a>



SEARCH RESULTS: Your search results need to be modified to display the detailed page when d=1. Replace your current results loop with the following in your search_results.html template:

<%if d eq '1'%> <!-- view detailed record -->
<%loop results%>
<%include record_dbs_detail.html%>
<%endloop%>
<%else%> <!-- List results -->
<%include record_dbs.html%>
<%endif%>


RECORD TEMPLATE: This is now used to show the basic search results that link to the detailed pages. You might want to edit this template to show only a limited number of fields, along with the link to the detailed page. The format and layout is up to you.



DETAILED RECORD TEMPLATE: You now use this detailed record template to display all the record info and the main photo and associated thumbnails. To do this we use the p=x variable to denote the photo to display, and <%if Thumb_xx> to display the thumbnails.

Where you want the main photo to be displayed, use the following template code (adjust it to suit your image field names and layout preferences):

Code:

<%if p eq '1'%> <!---view photo 1 large-->
<img src="db.cgi?db=dbs;do=view_file;cn=Photo_xx;id=<%ID%>" border=1>
<%elsif p eq '2'%> <!---view photo 2 large-->
<img src="db.cgi?db=dbs;do=view_file;cn=Photo_xx;id=<%ID%>" border=1>
<%elsif p eq '3'%> <!---view photo 3 large-->
<img src="db.cgi?db=dbs;do=view_file;cn=Photo_xx;id=<%ID%>" border=1>
etc ... etc ...
<%else%>
&nbsp;
<%endif%>



Use the following for the thumbnails (note how p=x changes to denote a different main photo to display!):

Code:

<%if Thumb_01%>
<a href="db.cgi?db=dbs;do=search_results;d=1;ID=<%ID%>;p=1">
<img src="db.cgi?db=dbs;do=view_file;cn=Thumb_01;id=<%ID%>" border=1>
</a>
<%endif%>

<%if Thumb_02%>
<a href="db.cgi?db=dbs;do=search_results;d=1;ID=<%ID%>;p=2">
<img src="db.cgi?db=dbs;do=view_file;cn=Thumb_02;id=<%ID%>" border=1>
</a>
<%endif%>


etc ...



That pretty much covers the changes - the layout and format are all up to you.

I hope you manage to get it working (sorry, but its been a few years since I modified it) and if you have any major problems, please feel free to email me.


All the best
Shaun