Page 1 of 1

Gallery images - can you just show first?

Posted: Wed Jun 16, 2010 4:49 am
by simonmlewis

Code: Select all

echo "<div class='productgallerybox'>";
			
			$string = "$row->photo";
      $token = strtok($string,"|");
      while($token) {
      echo "
      <div>
      <a href='images/productphotos/$token' rel='lightbox[$row->id]' title='Enlarge' /><img  src='images/productphotos/small/$token' border='0' class='productsmallbox' alt='Enlarge'/></a></div>
  
";
$token = strtok("|");
}

echo "</div>
Is it possible to NOT have this loop - but stop at the first | ??

Re: Gallery images - can you just show first?

Posted: Wed Jun 16, 2010 5:17 am
by Phoenixheart
Your question is not clear at all I'm afraid.

Re: Gallery images - can you just show first?

Posted: Thu Jun 17, 2010 5:01 am
by simonmlewis
Sorry.

Code: Select all

echo "<div class='productgallerybox'>";
                       
                        $string = "$row->photo";
      $token = strtok($string,"|");
      while($token) {
      echo "
      <div>
      <a href='images/productphotos/$token' rel='lightbox[$row->id]' title='Enlarge' /><img  src='images/productphotos/small/$token' border='0' class='productsmallbox' alt='Enlarge'/></a></div>
 
";
$token = strtok("|");
}

echo "</div>
This code goes through a loop to find each image file in turn, and loops around at each | sign in the field.
I want it to STOP at the first |. But have no idea how.

We have a Primary Photo field, but have been asked to use the first image in the gallery as the main photo in other areas of the site.