Trying to access images via GalleryCoreApi

strixy

Joined: 2009-03-11
Posts: 3
Posted: Wed, 2009-03-11 16:31

I'm working through the API and trying to find image id's stored in albums using the album id.

ie:
GalleryCoreApi::loadEntitiesById($album_id)

I get information about the album, now I'm looking for that albums decedent albums and/or child item images id's.

Anyone have suggestions as to how I might go about this?

Thank you. :)

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2009-03-11 16:39

The best way to find out that kind of thing is to go through the source code and see how that handles the same issue, eg. for displaying an album.

In this case try this:
http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryCoreApi.html#methodfetchChildItemIds

 
strixy

Joined: 2009-03-11
Posts: 3
Posted: Wed, 2009-03-11 16:53

Good advice. I found and tried the fetchChildItemIds() previously and was gifted with an error. Unfortunately there is no error message tagged to it and a search hasn't produced any results.

Object id #14Array
(
[0] => GalleryStatus Object
(
[_stack] =>
[_errorCode] => 17
[_errorMessage] =>
[_stackTrace] => Array

I also tried fetchChildItemIdsIgnorePermissions() and got the same error.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2009-03-11 17:16

Then it sounds like you're not using the API correctly. You should be doing something like this:

list ($ret, $myItemsIdArray) = GalleryCoreAPI::fetchChildItemIds(...);
if ($ret) {
    return array ($ret, null)
}

The precise return depends on the context of your function. However, the rule that if you receive a non-null return code ($ret) from the API you should pass it back up the call chain still applies. Then your error and stack trace are printed to screen (if you're admin) correctly and you can trace the error.

This kind of structure is easily seen thousands of times over all through the Gallery code.

 
strixy

Joined: 2009-03-11
Posts: 3
Posted: Wed, 2009-03-11 18:25

I'm obviously just getting started on this and jumping in too quickly. I'll back up and poke around more in the future. I only have 2 hours to learn the API. Which is plenty right? ;)

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Wed, 2009-03-11 22:33

No, it's good to jump straight in. But start by copying chunks of code from the existing installation.