Callback problem
vfortin
Joined: 2007-05-23
Posts: 8 |
![]() |
Hi there, Following the instructions on this page: But when I call it with {g->callback type="core.LoadChildren" item=$item|default:$theme.item I get this error message: Notice: Undefined index: core
This is likely a PHP/Smarty newbie error. Thanks! |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
your example is missing the closing "}" curly bracket. > Notice: Undefined index: core isn't that accompanied by a file / line number? check your code in Callbacks.inc, and the code you added in the .tpl file. -------------- |
|
vfortin
Joined: 2007-05-23
Posts: 8 |
![]() |
Thanks valiant, The callback I'm trying to write is nothing more than a modified LoadPeers. I want to retrieve the album children instead of the peers. I'm suspecting one of the GalleryCoreApi function to return an empty array but my PHP knowledge stops here. This is the call from the album.tpl: {g->callback type="core.LoadChildren" item=$child windowSize=$windowSize|default:$theme.params.maxMicroThumbs addEnds=false loadThumbnails=true}
...and this is the callback: case 'LoadChildren': $item = $params['item']; if (isset($item->getChildrenFunction)) { $parent = $item; list ($ret, $peerIds) = call_user_func($parent->getChildrenFunction, $userId); if ($ret) { return $ret; } } else if ($item['id'] > 0) { list ($ret, $canViewParent) = GalleryCoreApi::hasItemPermission($item['id'], 'core.view', $userId); if ($ret) { return $ret; } if ($canViewParent) { list ($ret, $parent) = GalleryCoreApi::loadEntitiesById($item['id']); if ($ret) { return $ret; } list ($ret, $peerIds) = GalleryCoreApi::fetchChildItemIds($item, null, null, $userId); if ($ret) { return $ret; } } } if (!empty($peerIds)) { foreach ($peerIds as $i => $id) { if ($id == $item['id']) { $peerItemIndex = $i; break; } } } if (isset($peerItemIndex)) { $windowSize = isset($params['windowSize']) ? ($params['windowSize'] - 1) : 6; $addEnds = isset($params['addEnds']) ? $params['addEnds'] : true; $peerLast = count($peerIds) - 1; $peerNeighborStart = max($peerItemIndex - (int)($windowSize/2), 0); $peerNeighborEnd = min($peerItemIndex + (int)(($windowSize+1)/2), $peerLast); /* If the window is pinned to one end, expand it to the entire windowSize */ if ($peerNeighborStart == 0) { $peerNeighborEnd = min($peerLast, $windowSize); } else if ($peerNeighborEnd == $peerLast) { $peerNeighborStart = max($peerLast - $windowSize, 0); } if ($peerNeighborStart > 0 && $addEnds) { $peerMap[0] = $peerIds[0]; } for ($i = $peerNeighborStart; $i <= $peerNeighborEnd; $i++) { $peerMap[$i] = $peerIds[$i]; } if ($peerNeighborEnd < $peerLast && $addEnds) { $peerMap[$peerLast] = $peerIds[$peerLast]; } list ($ret, $peerItems) = GalleryCoreApi::loadEntitiesById($peerMap); if ($ret) { return $ret; } if (!empty($params['loadThumbnails'])) { list ($ret, $thumbTable) = GalleryCoreApi::fetchThumbnailsByItemIds($peerMap); if ($ret) { return $ret; } } $j = 0; foreach ($peerMap as $i => $id) { $peer = (array)$peerItems[$j++]; $peer['peerIndex'] = $i + 1; if (isset($thumbTable[$id])) { $peer['thumbnail'] = (array)$thumbTable[$id]; } $peers[] = $peer; } $block['core']['LoadChildren'] = array('peers' => $peers, 'peerCount' => count($peerIds), 'thisPeerIndex' => $peerItemIndex + 1, 'parent' => (array)$parent); } else { $block['core']['LoadChildren'] = array('peers' => array(), 'peerCount' => 0); } return null; |
|
erlis
Joined: 2004-01-16
Posts: 205 |
![]() |
Did you manage to get LoadChildren to work? |
|
vfortin
Joined: 2007-05-23
Posts: 8 |
![]() |
Nope, sorry. |
|
erlis
Joined: 2004-01-16
Posts: 205 |
![]() |
Found a soution for our problem http://gallery.menalto.com/node/44573#comment-250873. |
|