ZenphotoCMS Forum
Is getNumsubalbums(); problematic in a dynamic album context ? - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Is getNumsubalbums(); problematic in a dynamic album context ? (/thread-2356.html)



Is getNumsubalbums(); problematic in a dynamic album context ? - edasque - 2008-03-06

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 :

`

                    `

(Can this be moved to Usage instead of Installation, my bad)




Is getNumsubalbums(); problematic in a dynamic album context ? - edasque - 2008-03-06

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

}

}

`




Is getNumsubalbums(); problematic in a dynamic album context ? - edasque - 2008-03-06

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 ?




Is getNumsubalbums(); problematic in a dynamic album context ? - sbillard - 2008-03-07

Please file a ticket on these problems. We will try to get them fixed. (Damn, these dynamic albums are complex!)




Is getNumsubalbums(); problematic in a dynamic album context ? - edasque - 2008-03-07

They sure are but what a very powerful feature you've created !

Ticket is here




Is getNumsubalbums(); problematic in a dynamic album context ? - edasque - 2008-04-04

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.




Is getNumsubalbums(); problematic in a dynamic album context ? - sbillard - 2008-04-04

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.




Is getNumsubalbums(); problematic in a dynamic album context ? - edasque - 2008-04-05

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.