mediasix Posted June 14, 2008 Share Posted June 14, 2008 Hi, I have made a working gallery using the flickr api, it is all working great, but I want to put an exception in and cant figure out how to do it. Basically the code pulls all of my sets from flickr then displays all of the photos contained in those sets, but there is one set that I do not wish to be displayed. How can I put that in my code?? Here is the code: <?php require_once("./includes/phpflickr/phpFlickr.php"); $f = new phpFlickr("MY API KEY"); $photosets = $f->photosets_getList('MY FLICKR USER'); if(!empty($photosets)){ foreach ($photosets['photoset'] as $set) { $setid = $set[id]; $photosSetInfo = $f->photosets_getInfo($setid); $heading = $photosSetInfo['title']; $photos = $f->photosets_getPhotos($setid, NULL, 2); $html = "<li class='accordion_toggle_container'><a href='#' class='accordion_toggle'>".$heading."</a></li> \n <li class='accordion_content'> \n <ol class='photos'> \n"; // Get the friendly URL of the user's photos $person = $f->people_findByUsername($user_id); $photos_url = $f->urls_getUserPhotos($person['id']); foreach ($photos['photo'] as $photo) { $html .= "<li class='photo'>$photodate1<a href='".$f->buildPhotoURL($photo, "medium")."' class='lightview' rel='gallery[".$heading."]'><img alt='$photo[title]' src='".$f->buildPhotoURL($photo, "Square")."'/></a></li> \n"; } echo $html; echo "</ol>\n </li>\n"; } } ?> And this is what I want to do: <?php require_once("./includes/phpflickr/phpFlickr.php"); $f = new phpFlickr("MY API KEY"); $photosets = $f->photosets_getList('MY FLICKR USER'); if(!empty($photosets)){ foreach ($photosets['photoset'] as $set **EXCEPT PHOTOSET '72157605601956344'**) { $setid = $set[id]; $photosSetInfo = $f->photosets_getInfo($setid); $heading = $photosSetInfo['title']; $photos = $f->photosets_getPhotos($setid, NULL, 2); $html = "<li class='accordion_toggle_container'><a href='#' class='accordion_toggle'>".$heading."</a></li> \n <li class='accordion_content'> \n <ol class='photos'> \n"; // Get the friendly URL of the user's photos $person = $f->people_findByUsername($user_id); $photos_url = $f->urls_getUserPhotos($person['id']); foreach ($photos['photo'] as $photo) { $html .= "<li class='photo'>$photodate1<a href='".$f->buildPhotoURL($photo, "medium")."' class='lightview' rel='gallery[".$heading."]'><img alt='$photo[title]' src='".$f->buildPhotoURL($photo, "Square")."'/></a></li> \n"; } echo $html; echo "</ol>\n </li>\n"; } } ?> Any help would be apreciated Thanks, mediasix Quote Link to comment https://forums.phpfreaks.com/topic/110199-help-i-need-an-exception/ Share on other sites More sharing options...
Progr@mmer Posted June 14, 2008 Share Posted June 14, 2008 That is how it should be. <?php require_once("./includes/phpflickr/phpFlickr.php"); $f = new phpFlickr("MY API KEY"); $photosets = $f->photosets_getList('MY FLICKR USER'); if(!empty($photosets)){ foreach ($photosets['photoset'] as $set) { $setid = $set[id]; if ( $setid == '72157605601956344' ) continue; $photosSetInfo = $f->photosets_getInfo($setid); $heading = $photosSetInfo['title']; $photos = $f->photosets_getPhotos($setid, NULL, 2); $html = "<li class='accordion_toggle_container'><a href='#' class='accordion_toggle'>".$heading."</a></li> \n <li class='accordion_content'> \n <ol class='photos'> \n"; // Get the friendly URL of the user's photos $person = $f->people_findByUsername($user_id); $photos_url = $f->urls_getUserPhotos($person['id']); foreach ($photos['photo'] as $photo) { $html .= "<li class='photo'>$photodate1<a href='".$f->buildPhotoURL($photo, "medium")."' class='lightview' rel='gallery[".$heading."]'><img alt='$photo[title]' src='".$f->buildPhotoURL($photo, "Square")."'/></a></li> \n"; } echo $html; echo "</ol>\n </li>\n"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/110199-help-i-need-an-exception/#findComment-565499 Share on other sites More sharing options...
mediasix Posted June 14, 2008 Author Share Posted June 14, 2008 That is most excellent , Thank you! One question I have, what if there are multiple sets I want to exclude?? Thanks in advance, mediasix Quote Link to comment https://forums.phpfreaks.com/topic/110199-help-i-need-an-exception/#findComment-565571 Share on other sites More sharing options...
Progr@mmer Posted June 14, 2008 Share Posted June 14, 2008 you have to add the sets ID to the array $excluded_sets you are welcome <?php // Make an array of the sets you want to exclude $excluded_sets = Array ( '1', '2','3' ); require_once("./includes/phpflickr/phpFlickr.php"); $f = new phpFlickr("MY API KEY"); $photosets = $f->photosets_getList('MY FLICKR USER'); if(!empty($photosets)){ foreach ($photosets['photoset'] as $set) { $setid = $set[id]; if ( in_array($setid, $excluded_sets) ) continue; $photosSetInfo = $f->photosets_getInfo($setid); $heading = $photosSetInfo['title']; $photos = $f->photosets_getPhotos($setid, NULL, 2); $html = "<li class='accordion_toggle_container'><a href='#' class='accordion_toggle'>".$heading."</a></li> \n <li class='accordion_content'> \n <ol class='photos'> \n"; // Get the friendly URL of the user's photos $person = $f->people_findByUsername($user_id); $photos_url = $f->urls_getUserPhotos($person['id']); foreach ($photos['photo'] as $photo) { $html .= "<li class='photo'>$photodate1<a href='".$f->buildPhotoURL($photo, "medium")."' class='lightview' rel='gallery[".$heading."]'><img alt='$photo[title]' src='".$f->buildPhotoURL($photo, "Square")."'/></a></li> \n"; } echo $html; echo "</ol>\n </li>\n"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/110199-help-i-need-an-exception/#findComment-565609 Share on other sites More sharing options...
mediasix Posted June 17, 2008 Author Share Posted June 17, 2008 legend! thanks a lot, i knew it would have to be an array but again wasnt sure hwere. thank you so much. mediasix Quote Link to comment https://forums.phpfreaks.com/topic/110199-help-i-need-an-exception/#findComment-567222 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.