Navigating Sub-albums

How does one navigate sub-albums programmatically? If I call getAlums on a gallery, it only gives me the high level albums. I called getNumAlbums() on an album that had sub albums and got the count of the albums. The getNext and getPrev functions only return albums at the same level. What do I call to get a sub album object?

Comments

  • acrylian Administrator, Developer
  • There's nothing on that page about accessing sub albums. Is there a method on a class in your framework that returns a pointer to a sub-allbum? I've looked through Album and AlbumBase can't find a method that does so.

    Here's the code I have so far

    $gallery = new Gallery();
    $numAlbums = $gallery->getNumAlbums();
    $gallery->getAlbums();
    for ($i = 0; $i < $numAlbums; $i++)
    {
    $album = $gallery->getAlbum($i);
    $title = $album->getTitle(); echo $title;
    if ($title == "Flora and Fauna") break;
    }
    $floraAndFauna = $album->getAlbums();
    $numSubAlbums = $album->getNumAlbums();

    The method getAlbums returns the names of the sub albums. The method getNumAlbums returns the number of the sub albums. I need a pointer to the sub album object. There's a method getParent that would presumably get me the parent of a sub album so there must be a way to get to the child.
  • I found this in the framework doc:

    If you want to create an object of a subalbum the name must include the parent album name(s) like "toplalbumfoldername/subalbum1folder/subalbum2folder" (etc);

    This would work if I was willing to hard code the name of one of the sub albums. I want the code to be dynamic in that it would process any sub album it found if any.
  • OK, I think I have it figured out. You call getAlbums to get the names and then do a new on each.
  • acrylian Administrator, Developer
    Yes, that's it, best recursively so you get all levels exisiting.
Sign In or Register to comment.