The Breadcrumb code in an embed page

silvercrow
silvercrow's picture

Joined: 2008-05-25
Posts: 2
Posted: Tue, 2009-09-15 01:46

Hi guys Im using a custom embed page for gallery2 and it works great with my site but I want to use the breadcrumb in another place I mean out of the generated code. I was able to do it with other stuff like the title, the javascript and the css using the function runGallery but I dont know how to call the BreadCrumb like this.
Here is the code I use.

Quote:
function runGallery() {
$data = array();

// if anonymous user, set g2 activeUser to ''
$uid = '';

// initiate G2

$ret = GalleryEmbed::init(array('g2Uri' => '/gallery2/',
'embedUri' => 'index.php',
'activeUserId' => $uid));
$ret = GalleryEmbed::setThemeForRequest('siriux');
if ($ret) {
$data['bodyHtml'] = $ret->getAsHtml();
return $data;
}

// user interface: you could disable sidebar in G2 and get it as separate HTML to put it into a block
// GalleryCapabilities::set('showSidebarBlocks', false);

// handle the G2 request
$g2moddata = GalleryEmbed::handleRequest();

// show error message if isDone is not defined
if (!isset($g2moddata['isDone'])) {
$data['bodyHtml'] = 'isDone is not defined, something very bad must have happened.';
return $data;
}
// exit if it was an immediate view / request (G2 already outputted some data)
if ($g2moddata['isDone']) {
exit;
}

// put the body html from G2 into the xaraya template
$data['bodyHtml'] = isset($g2moddata['bodyHtml']) ? $g2moddata['bodyHtml'] : '';

// get the page title, javascript and css links from the <head> html from G2
$title = ''; $javascript = array(); $css = array();

if (isset($g2moddata['headHtml'])) {
list($data['title'], $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']);
$data['headHtml'] = $g2moddata['headHtml'];
}

/* Add G2 javascript */
$data['javascript'] = '';
if (!empty($javascript)) {
foreach ($javascript as $script) {
$data['javascript'] .= "\n".$script;
}
}

/* Add G2 css */
$data['css'] = '';
if (!empty($css)) {
foreach ($css as $style) {
$data['css'] .= "\n".$style;
}
}

// sidebar block
if (isset($g2moddata['sidebarBlocksHtml']) && !empty($g2moddata['sidebarBlocksHtml'])) {
$data['sidebarHtml'] = $g2moddata['sidebarBlocksHtml'];
}

return $data;
}

Thanks a lot and check my site to see the gallery working. http://www.silvercrow.org/gallery/

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2009-09-15 02:16

The breadcrumb html is part of the $g2moddata['bodyHtml']
you would need to try and parse it out, or use javascript to get the innerHTML of the breadcrumb's container and transport it elsewhere.

I have an easy to use G2 embed form.

I also have a function in my jQuery mediaBlock for reproducing breadcrumbs by id:

function returnBreadcrumbs($id) {
    global $gallery;
    $display = '';
    /* Get ids of all parent albums filtering for rootBreadcrumbId */
    list($ret, $ids) = GalleryCoreApi::fetchParentSequence($id, true);
    if ($ret) {
        return "Error in fetchParentSequence in function returnBreadcrumbs:".$ret->getAsHtml();
    }
    if (! empty($ids)) {
        list($ret, $albums) = GalleryCoreApi::loadEntitiesById($ids, 'GalleryAlbumItem');
        if ($ret) {
            return "Error in loadEntitiesById in function returnBreadcrumbs:".$ret->getAsHtml();
        }
        foreach ($albums as $album) {
            $display .= '<a class="breadcrumb" href="#" onclick="performRequest(\'#theContent\', buildUrl(\'#theContent\', '.$album->getId().'));return false;">'.$album->getTitle().'</a> » ';
        }
    }
    /* Load and Add our starting point */
    list($ret, $startAlbum) = GalleryCoreApi::loadEntitiesById($id, 'GalleryAlbumItem');
    if ($ret) {
        return array($ret->getAsHtml(), null);
    }
    $display .= '<a class="breadcrumb">'.$startAlbum->getTitle().'</a>';
    return rtrim($display, ' » ');
}

Regular mediaBlock here.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
silvercrow
silvercrow's picture

Joined: 2008-05-25
Posts: 2
Posted: Tue, 2009-09-15 05:57

Thanks dude Im going to play with the code tomorrow.