Member
Member
gcortes   26-10-2013, 17:39
#1

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?

Administrator
Administrator
acrylian   26-10-2013, 17:42
#2

Using the object model framework:
http://www.zenphoto.org/news/zenphotos-object-model-framework

Member
Member
gcortes   26-10-2013, 20:19
#3

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 (&#36;i = 0; &#36;i < &#36;numAlbums; &#36;i++)
{
&#36;album = &#36;gallery->getAlbum(&#36;i);
&#36;title = &#36;album->getTitle(); echo &#36;title;
if (&#36;title == "Flora and Fauna") break;
}
&#36;floraAndFauna = &#36;album->getAlbums();
&#36;numSubAlbums = &#36;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.

Member
Member
gcortes   26-10-2013, 20:25
#4

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.

Member
Member
gcortes   26-10-2013, 20:49
#5

OK, I think I have it figured out. You call getAlbums to get the names and then do a new on each.

Administrator
Administrator
acrylian   26-10-2013, 21:02
#6

Yes, that's it, best recursively so you get all levels exisiting.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.