[SOLVED] Is there a way to import the children array without changing pageType from 'photo' to 'album'?

grittykitty
grittykitty's picture

Joined: 2010-11-04
Posts: 7
Posted: Thu, 2010-11-04 05:34

Creating new theme in Gallery 2.3.

When displaying a photo you are presented with previous and next icons. Currently looks like this:

< 1 of 78 >

It is very inconvenient to press NEXT 54 times just to display Image #55.

Would like to display a navigation bar that allows me to enter the image #. For example,

< Image [ 1 ] of 78 >

The [ 1 ] is an input field that allows me to change the number and select enter and I will be redirected to the item.id that is related with, for example, image #55.

The problem is that the $theme.children[] is empty when $theme.pageType = photo.

Any idea how I can get a list of all the children without having to create an AJAX pull from the main Album, i.e., a page that has $theme.pageType = album?

Any help is greatly appreciated.

Best...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2010-11-04 11:13

theme.inc, add your template variable => value there.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
grittykitty
grittykitty's picture

Joined: 2010-11-04
Posts: 7
Posted: Thu, 2010-11-04 12:58

Most excellent. Thank you for the quick response. Digging now.

-gK

 
grittykitty
grittykitty's picture

Joined: 2010-11-04
Posts: 7
Posted: Thu, 2010-11-04 14:11

At first glance at the theme.inc it looks like I need to do the following to include children[] in the Photo page...

This is for showAlbumPage...

function showAlbumPage(&$template, $item, $params, $childIds) {

This is for showPhotoPage...

function showPhotoPage(&$template, $item, $params) {

It appears that I must add $childIds to the showPhotoPage90 function, but naturally this yields an error.

"PHP Warning: Missing argument 4 for ..., called in ..\modules\core\classes\GalleryTheme.class on line 938"

For fun, I practially copied all the information from the showAlbumPage() function to the showPhotoPage() function and I was never able to get children => Array(0) to populate, which implied that I need to pass $childIds into showPhotoPage().

What fun.

-gK

 
grittykitty
grittykitty's picture

Joined: 2010-11-04
Posts: 7
Posted: Thu, 2010-11-04 14:20

Looks like I need to understand this better before I can get a list of children for a particular parent to be included in showPhotoPage() function.

GalleryCoreApi::fetchChildItemIds

Off into the darkness I go...

-gK

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2010-11-04 21:48

http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryCoreApi.html#methodfetchChildItemIds

basically something like:

    // Load the parent first.
    list($ret, $parent) = GalleryCoreApi::loadEntitiesById($item->getId(), 'GalleryItem');
    if ($ret) {
        return array($ret, null);
    }
    // Load the childItemIds.
    list($ret, $childIds) = GalleryCoreApi::fetchChildItemIds($parent);
    if ($ret) {
        return array($ret, null);
    }
    // Then load all the childItems
    list($ret, $childItems) = GalleryCoreApi::loadEntitiesById($childIds, 'GalleryItem');
    if ($ret) {
        return array($ret, null);
    }
    // Then set your template variable - Make it unique as not to conflict with another.
    $template->setVariable('allChildren', $childItems);

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
grittykitty
grittykitty's picture

Joined: 2010-11-04
Posts: 7
Posted: Fri, 2010-11-05 02:15

Just coming back to the drawing board now... your insight is more than appreciated. Thank you for the time and effort to reply to this problem. I will work on this further tonight and digest what you have provided and try and assemble the pieces.

-gK

 
grittykitty
grittykitty's picture

Joined: 2010-11-04
Posts: 7
Posted: Fri, 2010-11-05 05:09

Nice suprsidr. You're a genius.

I just had to tweak the 1st line and I got an array of $allChildren with reference pointers to all the children data. Wee... just what I needed.

Not only did you provide the code necessary to complete the task, but you also taught me how to utiliize some of the GalleryCoreApi routines, which was another issue.

Eternally grateful! Nice job!

-gK

Below is the complete showPhotoPage function.

function showPhotoPage(&$template, $item, $params) {
// Load the parent first.
list($ret, $parent) = GalleryCoreApi::loadEntitiesById($item->getParentId(), 'GalleryItem');
if ($ret) return array($ret, null);
// Load the childItemIds.
list($ret, $childIds) = GalleryCoreApi::fetchChildItemIds($parent);
if ($ret) return array($ret, null);
// Then load all the childItems
list($ret, $childItems) = GalleryCoreApi::loadEntitiesById($childIds, 'GalleryItem');
if ($ret) return array($ret, null);
// Then set your template variable - Make it unique as not to conflict with another.
$template->setVariable('allChildren', $childItems);
$datatypes = array('owner', 'parents', 'systemLinks', 'itemLinks', 'permissions', 'itemLinksDetailed', 'itemNavigator', 'imageViews');
$ret = $this->loadCommonTemplateData($template, $item, $params, $datatypes);
if ($ret) return array($ret, null);
$theme =& $template->getVariableByReference('theme');
if (isset($theme['navigator']['first'])) unset($theme['navigator']['first']);
if (isset($theme['navigator']['last'])) unset($theme['navigator']['last']);
return array(null, 'theme.tpl');
}

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2010-11-06 01:40

I would like to see your new theme in operation, got a link?
Care to share your creation?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
grittykitty
grittykitty's picture

Joined: 2010-11-04
Posts: 7
Posted: Sat, 2010-11-06 05:01

I'd love to. Here's a sample site using the basic skin.

http://www.asynccomputing.com/gallery/main.php?g2_itemId=2215

I have modified
../modules/core/templates/userlogin.tpl
../modules/core/templates/block/Navigator.tpl

It would be greatly appreciated if anyone has insight into how to add these files to the template/skin without affecting the original Gallery2 files. I tried to mimic the folder structure, but the template did not take my Navigator.tpl changes.

Pagination has been added to the parent Album view and the children Photo view. It's simple, but at least people can now select a page or photo without having to press NEXT a dozen times.

-gK