Is getNumsubalbums(); problematic in a dynamic album context ?

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 .= ",&nbsp"; }

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

  • After looking a bit into it, I am guessing the first issue (printing a total number of subalbums in the dynamic albums instead of printing the number of subalbums in a subalbum of the dynamic albums) is because of this code which behaves differently whether it's a search (or dynamic album) or a static album:

    ` 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());

    }

    }

    `

  • as for getNumImages(), I am guessing it fails because it thinks it's being called in a dynamic album context but in my case it is called in a subalbum context of a dynamic album. Makes sense ?
  • Please file a ticket on these problems. We will try to get them fixed. (Damn, these dynamic albums are complex!)
  • They sure are but what a very powerful feature you've created !

    Ticket is here
  • This is fixed but the old dynamic album creation left a trailing '.' at the end of the query. I had to re-create them all since the UI no longer allows for editing the query.
  • Sorry about that. We felt it better to not let the query be edited. Then we won't have to respond to problems created by the editing. It is relatively simple to recreate the album from a query. There should not have abeen a "." at the end anyway, but it probably did no harm.
  • Well, not exactly, I think the old queries had a trailing '.' which in the latest night builds stop functioning. After redoing the albums from a query all is well now, of course.
Sign In or Register to comment.