getAlbums does not list all albums

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

Comments

  • 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 :(
  • acrylian Administrator, Developer
    What exactly is the bug? If an album is unpublished it is inherited by all children as with rights and passwords.
  • 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.
  • acrylian Administrator, Developer
    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.
  • any examples?? Or can you explian a bit more?
  • 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;
    }
    `
  • 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;
    }
    `
  • acrylian Administrator, Developer
    So it is solved then?
  • 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.
Sign In or Register to comment.