Problem with embed code

.santiago

Joined: 2006-03-09
Posts: 5
Posted: Thu, 2006-03-09 22:28

I hope someone can help me with this:

I was integrating Gallery2 in my own site but some things like images, login menu and css styles doesn't appear.

Here's the page i'm working: http://www.el-entrepiso.com.ar/arte_prueba.php
And here's the standalone gallery2 into my site using Siriux theme (that's the way i want to see things in the page i'm working): http://www.el-entrepiso.com.ar/galeria

Inside it i use the following embed code:

Quote:
<?php

/*
* This is an example of how G2 can be wrapped into your own website
* If you only want to embed G2 visually in your website, you don't need GalleryEmbed (so this
* approach is not necessarily what you want). But if you want to embed G2 in your website,
* including a unified user management, a single login etc., then this is the correct file to
* start with.
*/

/*
* runGallery() exits if G2 tells it to so (by isDone = true). It's important that you don't
* output any html / anything before you call runGallery (which calls
* GalleryEmbed::handleRequest), else, G2 won't work correctly.
* Reason: G2 does a lot of redirects. E.g. when you login, it redirects to the next page, etc.
* and redirects won't work if there was already some output before the redirect call.
*/
$data = runGallery();
$data['title'] = (isset($data['title']) && !empty($data['title'])) ? $data['title'] : 'Gallery';

if (isset($data['bodyHtml'])) {
print <<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>{$data['title']}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
{$data['javascript']}
{$data['css']}
</head>

<body>
{$data['bodyHtml']}
</body>
</html>
EOF;
}

function runGallery() {

require_once('./galeria/embed.php');

$data = array();

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

// initiate G2
$ret = GalleryEmbed::init(array('g2Uri' => '/galeria/',
'embedUri' => '/arte_prueba.php',
'activeUserId' => $uid));
if ($ret->isError()) {
$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;
}

?>

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2006-03-10 08:05

the basic functionality seems to work fine but you make some newbie mistakes :)
like outputting html before calling GalleryEmbed::handleRequest(), that's why the breadcrumb links don't work.
and you'll have to fix css issues of course.