GalleryAlbumItem Children

lam1101

Joined: 2009-09-01
Posts: 2
Posted: Tue, 2009-09-01 17:48

Hi All,

I’m trying to get a list of all the albums I have in my Gallery2 installation through the GalleryCoreApi. Currently, I have a test setup with 4 users, each with their own personal albums and a small handful of images in the albums.

I have tried:

list ($error,$top_album_id) = GalleryCoreApi::getDefaultAlbumId();
list($error,$albums) = GalleryCoreApi::loadEntitiesById($top_album_id);

This gives me back a GalleryAlbumItem. Since all the user albums look like they are children of the top “Gallery” album, I thought I could just grab all the children of the GalleryAlbumItem by using GalleryCoreApi::fetchChildItemIds. Unfortunately, the GalleryAlbumItem doesn’t seem to have any children.

What am I doing wrong? I’m pretty sure I am so completely confused at this point that I’ve missing something obvious or am looking in the completely wrong area for the solution.

All I want to do is programmatically get PHP object representations of all the albums in my Gallery. Any help would be appreciated.

Thanks

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2009-09-01 18:46

I don't know how to do this, but what is your end goal? What are you trying to accomplish? It may have already been done.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
lam1101

Joined: 2009-09-01
Posts: 2
Posted: Wed, 2009-09-02 13:47

I'm trying to debug my installation of the g2image plug in. Unfortunately, I haven't been able to get the correct behavior and all my attempts to figure out if some configuration is incorrect have been fruitless.

The plug in isn't able to find any of the user albums that I have set up. After being completely stumped, I decided to trace through the plug in's code to figure out what is failing. (I'm much more comfortable tracing code paths than understanding the complexities of configuration). It appears the issue is that none of the albums are being returned by any of the GalleryCoreApi function calls. I'm guessing this is a side effect of the real problem.

I'm trying to figure out the prescribed way of accessing all albums through the GalleryCoreApi so that I can continue hunting down my problem. I believe if I can understand the API design for accessing this information, I will be able to determine what is wrong with either my installation or configuration.

Of course, I could also be over complicating this. :-/

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2009-09-07 15:43

Hmmm, I wish I could help out with this, but it's above my head. I can only point you to the development docs:
http://gallery.menalto.com/dev

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2009-09-07 17:57

Your approach is correct; use lines like

print '<pre>'; print_r($my_datastructure); print '</pre>';

liberally through your code to see what $my_datastructure is.

Incidentally there's a potential typo in your sample code that may stem from a more significant misunderstanding on your part. You write:

list($error,$albums) = GalleryCoreApi::loadEntitiesById($top_album_id);

However loadEntities called on a numeric type returns a single GalleryEntity and not an array so your variable should be $album (or better, $top_album - or better yet obey G2 coding conventions on camelCase and call it $topAlbum). Don't forget to use the recommended $requiredEntityType field either.