Search the Community
Showing results for tags 'echo count'.
-
Hi guys Managed to get a complex (to me anyway) image count and if/else echo going. <?php // if Background_Image contains more than 1 echo those images in a slideshow if($page->Background_Image->count > 1 ){ $bgimage = $page->Background_Image; foreach ($bgimage as $image) { echo" <script> $.backstretch('$image->url'); </script> ";} } else // otherwise echo a single image on its own if($page->Background_Image->count == 1 ){ $bgimage = $page->Background_Image; foreach ($bgimage as $image) { echo" <script> $.backstretch(['$image->url',], {duration: 3000, fade: 750}); </script> ";} } ?> I'm not sure how to handle the last part of the echo though. The Script I'm using says that an image slideshow should be outputted in following format $.backstretch([ "http://dl.dropbox.com/u/515046/www/outside.jpg" , "http://dl.dropbox.com/u/515046/www/garfield-interior.jpg" , "http://dl.dropbox.com/u/515046/www/cheers.jpg" ], {duration: 3000, fade: 750}); IE each image needs a comma but the last image should have no comma then a square bracket and then the remainder. With my code, I'm currently getting three separate <script> $.backstretch('/site/assets/files/1/016---dc3420.jpg'); </script> <script> $.backstretch('/site/assets/files/1/021---dc3420.jpg'); </script> <script> $.backstretch('/site/assets/files/1/photo-bathroom.jpeg'); </script> instead of the desired structure