PDA

View Full Version : Looping through images


shogton
20th of August 2004 (Fri), 04:17
Hi there, I would like to be able to loop through my images continuously as I click previous and next on the photo page.

I have a rough idea what I want to do, but not the php skills to do it. I wonder if any of you fellows out there might be able to help?

The bit of code I am looking at is in photo.php .....


ob_start();
//print "this_photo: " . $this_photo;
reset($link_id);
$break = "0";
// PRINT PREVIOUS LINK
if (isset($link_id)) {
@$linkbackward = $link_id[($this_photo-1)]["id"];
@$exhibition_backward = $link_id[($this_photo-1)]["exhibition"];
if (!$linkbackward) {
print "--------";
$break = "1";

}

if ($break == "0") {

$offsetlink_backward = $offset-1;

if ($export == "no") {
print "<a href=\"photo.php?photo=" . $linkbackward;
$temp = $uncookied;

if ($viewall == "1") {
$temp["exhibition"] = $exhibition_backward;
} else {
$temp["exhibition"] = $exhibition;
}
$uncookied_id = ee_uncookied_make ($temp);
print "&u={$uncookied_id}{$uncookied_splitter}{$offsetlin k_backward}{$uncookied_foochar}{$passparam}\"";
}
if ($export == "1") {
print "<a href=\"" . $linkbackward . ".html\"";
}
print " TITLE=\"" . ee_translate_A($translated["prev_alt_text"]) . "\">" . ee_translate_A($translated["previous"]) . "</a>";
}
}

$prevlink_html = ob_get_contents();
ob_end_clean();


There also follows the equivalent part for the "next" option, but if I get one working, the other should be easy to change. The part I want to change is ....


if (!$linkbackward) {
print "--------";
$break = "1";
}


If I reach the start of the array, I want to iterate back through it to the other end, so that $linkbackward points to the last image in the array.

Would I use some sort of loop to step through to the other end of the array or is there some way of querying the size of the array and putting the relevant index in?

I know roughly what I want, but my PHP brain has no idea how best to do it. Any ideas would be greatly appreciated.

many thanks,
Stuart.