|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Image gallery next/previous problem
Having been forced to revisit an old photoalbum reated seveal years ago, I've attempted to make some changes/improvements. But now I'm stuck, and this really is the last thing I wish to accomplish. So here's what I have so far (using fusebox).....
qry_photos.cfm --------------- <cfset serverdir = "d:\serverpath\photos\full\"> <cfset httpdir = "http://www.url.com/photos/full"> <!--- retrieve all JPGs ---> <cfdirectory name="getrecords" action="list" directory="#serverdir#" filter="*.jpg" > act_photos.cfm --------------- <cfparam name="displayamount" default="6"> <cfparam name="startrecord" default="1"> <cfif #getrecords.recordcount# GT (startrecord + (displayamount -1))> <cfset displaynext = startrecord + (displayamount -1)> <cfelse> <cfset displaynext = getrecords.recordcount> </cfif> <cfset count = 1> <cfloop query="getrecords" startrow="#startrecord#" endrow="#displaynext#"> <cfoutput> <cfset pic_array[count] = '#getrecords.name#'> <cfset count = count + 1> </cfoutput> </cfloop> and in dsp_photos.cfm --------------------- <h2>Photo Gallery</h2> <p>This is a collection of sample gallery photos from the Hokonui Fashion Awards</p><br / > <div id="gallery"> <cfoutput> <cfif getrecords.recordcount IS NOT 0> <cfif startrecord GT 1> <cfset prevrecord = (#startrecord# - #displayamount#)> <a href="#self#?fuseaction=#xfa.photos#&startrecord=#prevrecord#" class="prevnext">&##171; Previous</a> </cfif> <cfif getrecords.recordcount GT (#startrecord# + (#displayamount# - 1))> <cfset nextrecord = #displaynext# + 1> <a href="#self#?fuseaction=#xfa.photos#&startrecord=#nextrecord#" class="prevnext">Next &##187;</a> </cfif> <cfelse> <p>There are no images at this time.</p> </cfif> </cfoutput> <div style="width:360px; padding-top:10px;"> <cfloop from="1" to="#ArrayLen( pic_array )#" index="i"> <cfoutput> <cfif pic_array[i] EQ "0"> <cfelse> <a href="#self#?fuseaction=#xfa.photosFull#&imgsrc=#directoryFull##pic_array[i]#&returnrecord=#startrecord#"> <img src="#directoryTn##pic_array[i]#" alt="" height="150" width="100" /> </a> </cfif> </cfoutput> </cfloop> </div> </div> in dsp_photosFull.cfm the image is called like so.... <cfoutput><img src="#imgsrc#" border="0"><br /><br /> <a href="#self#?fuseaction=#xfa.photos#&startrecord=#returnrecord#" class="prevnext">Back to Thumbs</a> </cfoutput> At the outset I wasn't using an array since it wasn't initially a requirement for any output. But now I wish to click on one of the thumbnail images displayed in dsp_photos.cfm and open that image in dsp_photosFull.cfm. So far this is working fine. But now I also want a previous/next button on this page that will display the next (or previous) full image (without returning to the thumbnails page) hence the use of an array. This has to work even when I'm viewing the last full size image of the current array (ie the 6th image of the array, so the "next" image will be the first result from the next arrray set) I hope this makes sense. Any ideas?? All help appreciated TIA MarkH |
|
#2
|
|||
|
|||
|
What exactly is the problem now? It will let you go forward and backward, but when you are at 6 it tries to go on to 7 when you hit next, and when you are at one it tries to go back to 0 when you hit previous?
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Quote:
On the dsp_photoFull.cfm page I don't actually know how to evaluate the current full image position so that I can work out which image should come next (and the same for previous). When I was tinkering with setting a previous and next values I did get an error saying that position 7 of the array was undefined (bI received this error when I was trying to evaluate the next and previous fields on dsp_photos.cfm)...so yes, what you outline is definitely one issue. Maybe arrays aren't the right idea here. Would one full list of all images be easier to work with (perhaps). |
|
#4
|
|||
|
|||
|
Lists probably wouldn't be any better than arrays. I guess I'm not sure why you can't determine if you're at the end or beginning of the list. You're passing the "position" in the array as a URL value, so can't you use that to determine where you are in the array? Am I missing something?
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Image gallery next/previous problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|