I have a dynamic album, let's call it Macro (
http://www.frenchguys.com/gallery/Techniques/Macros.alb/), it contains a static album called "Insect and Flowers" and a few photos. Its query is based on a tag called "macro".
For sub-albums, my album.php code displays the number of sub-albums it itself contains, the number of photos and how many times it was viewed.
Strangely, you'll see that the "Insect and Flowers" subalbums has different characteristics while viewed in Macros (
http://www.frenchguys.com/gallery/Techniques/Macros.alb) or BzzAgent Volunteering Day (
http://www.frenchguys.com/gallery/Others/BzzAgentFoodProject/).
The later is correct with 0 subalbums and 58 photos. I have tracked the problem here to `getNumsubalbums();` returning the wrong value for an album within a sub-album.
So it seems that `getNumsubalbums();` & `getNumImages();` don't work well in the context that I am using them in here. Which if I understand is within a dynamic-album, in the `while (next_album()):` loop, before the `while (next_image(false, $firstPageImages)):` loop.
Moreover, as a result of calling these functions, the image loop that comes after I close the `while (next_album()):` subalbums loop stops working and doesn't display the images of my context. I have tracked that to the `getNumImages();` call within the sub-albums loop. Removing it displays my images correctly.
Am I not using the right API calls ?
This is the additional code I am using within the `while (next_album()): loop` :
`
<?php <br />
$number = getNumsubalbums();
if ($number > 0) { //If there are sub albums
if (!($number == 1)) // If there is more than one use plural
{
$number .= " sub-albums";
}
else // Use singular
{
$number .=" sub-album";}
$counters = $number;
}
else // otherwise the string will be empty
{
$counters = '';
}
$number = getNumImages();
if ($number > 0)
{
if (!empty($counters)) { $counters .= ", "; }
if ($number != 1) $number .= " photos"; else $number .=" photo";
$counters .= $number;
}
if (!empty($counters)) // if the string is not empty, display it
{
echo "
$counters";
}
?>`
(Can this be moved to Usage instead of Installation, my bad)
Comments
` function getNumSubalbums() {
global $_zp_current_album, $_zp_current_search;
if (!is_null($_zp_current_search)) {
return count($_zp_current_search->getNumAlbums());
} else {
return count($_zp_current_album->getSubalbums());
}
}
`
Ticket is here