Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 8b79fb2

Browse files
committed
Fixed user example so it traverses groups too
1 parent 0fa6596 commit 8b79fb2

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

examples/example-user.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,26 @@
5656
$f = new phpZenfolio("AppName={$appname}");
5757
// Get list of recent galleries and collections
5858
$h = $f->LoadGroupHierarchy($username);
59-
// Get all the pictures in the first element
60-
$pictures = $f->LoadPhotoSetPhotos($h['Elements'][0]['Id'], 0, 100 );
61-
// Display the 60x60 cropped thumbnails and link to the photo page for each.
62-
foreach ($pictures as $pic) {
63-
echo '<a href="',$pic['PageUrl'],'"><img src="',phpZenfolio::imageUrl($pic, 1),'" title="',$pic['Title'],'" alt="',$pic['Id'],'" /></a>';
64-
}
59+
// Now traverse the tree and locate the first public gallery and display it's first 100 photos
60+
array_walk($h['Elements'], 'displayImgs', $f);
6561
}
6662
catch (Exception $e) {
6763
echo "{$e->getMessage()} (Error Code: {$e->getCode()})";
6864
}
65+
66+
function displayImgs($element, $key, $f) {
67+
if ( $element['$type'] == 'Group' ) {
68+
array_walk($element['Elements'], 'displayImgs', $f);
69+
} else {
70+
if ( $element['PhotoCount'] > 0 ) {
71+
$pictures = $f->LoadPhotoSetPhotos($element['Id'], 0, 100 );
72+
// Display the 60x60 cropped thumbnails and link to the photo page for each.
73+
foreach ($pictures as $pic) {
74+
echo '<a href="',$pic['PageUrl'],'"><img src="',phpZenfolio::imageUrl($pic, 1),'" title="',$pic['Title'],'" alt="',$pic['Id'],'" /></a>';
75+
}
76+
}
77+
}
78+
}
6979
?>
7080
</body>
7181
</html>

0 commit comments

Comments
 (0)