Jump to content

help, i need an exception!


mediasix

Recommended Posts

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

Link to comment
Share on other sites

:) 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";
}
}
?>

Link to comment
Share on other sites

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";
}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.