ZenphotoCMS Forum
getAlbums does not list all albums - 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: getAlbums does not list all albums (/thread-11070.html)



getAlbums does not list all albums - jphilbert - 2013-05-22

Is there any variable that will not show all albums when using the "getAlbums command?

This is what I do currently to get published/unpublished albums.
$albums = $gallery->getAlbums( null, null, null, null, true );




getAlbums does not list all albums - acrylian - 2013-05-22

http://www.zenphoto.org/documentation/classes/Gallery.html#methodgetAlbums
The last one.




getAlbums does not list all albums - jphilbert - 2013-05-23

Ok found a bug ... during testing this
$albums = $gallery->getAlbums( null, null, null, null, true );

Will not work if an unpublished album is under another unpublished album




getAlbums does not list all albums - acrylian - 2013-05-23

What exactly is the bug? If an album is unpublished it is inherited by all children as with rights and passwords.




getAlbums does not list all albums - jphilbert - 2013-05-23

Lets break it down...


2012 (main folder)
flowers (sub folder unpublished)
birds
insects


Now GetAlbums will list 2012 and flowers but anything under flowers will NOT show up..

Even with care listed as TRUE.




getAlbums does not list all albums - acrylian - 2013-05-23

Sorry, the gallery class getAlbums only gets teh toplevel as on the index page. For sublevels you need to recursively use the album methods as well.




getAlbums does not list all albums - jphilbert - 2013-05-23

any examples?? Or can you explian a bit more?




getAlbums does not list all albums - jphilbert - 2013-05-23

I guess I have to revise this function

function getSubAlbums( $gallery, $album ) { $list = array(); $albumObj = new Album( $gallery, $album ); $albumID = $albumObj->getID(); $parentID = getItemByID( "albums", $albumID ); if ( $albumObj->isDynamic() || !$albumID ) return $list; $subalbums = $albumObj->getAlbums(); $subalbums = $parentID->getAlbums(); if ( is_array( $subalbums ) ) { foreach ( $subalbums as $subalbum ) { $list[] = $subalbum; $list = array_merge( $list, getSubAlbums( $gallery, $subalbum ) ); } //$subalbums as $subalbum } //is_array($subalbums) return $list; }




getAlbums does not list all albums - jphilbert - 2013-05-24

I found the BUG it was me over looking my subalbums function SMH
function getSubAlbums( $gallery, $album ) { $list = array(); $albumObj = new Album( $gallery, $album ); $albumID = $albumObj->getID(); $parentID = getItemByID( "albums", $albumID ); if ( $albumObj->isDynamic() || !$albumID ) return $list; $subalbums = $albumObj->getAlbums( null, null, null, null, true ); $subalbums = $parentID->getAlbums( null, null, null, null, true ); if ( is_array( $subalbums ) ) { foreach ( $subalbums as $subalbum ) { $list[] = $subalbum; $list = array_merge( $list, getSubAlbums( $gallery, $subalbum ) ); } //$subalbums as $subalbum } //is_array($subalbums) return $list; }




getAlbums does not list all albums - acrylian - 2013-05-24

So it is solved then?




getAlbums does not list all albums - jphilbert - 2013-05-24

YEP solved ... false alarm. My main function with "getAlbums()" call my subalbums function I just missed that I needed to do getAlbums( null, null, null, null, true ) also so it can find all unpublished "NESTED" subfolders never had that situation before.