Thanks for your reply, code looks like what i need, but i can't get it working.
I'm still no expert in php, so it's probably a very simple thing that i'm missing here.
I tried to call your script this way:
$content = G2_sideBar();
But that leaves me an empty screen, nothing gets processed from that point on.
In my script i use $data = runGallery();
to initialise my gallery (rungallery() function posted below)
further down my page i call echo $data['bodyHtml'];
to display the gallery on that location.
Now i see you using the variable $g2_data, shouldn't that be $data?
Is this correct for my script?
$ret = G2B_G2_init();
or should i call a different function, because i can't find G2B_G2_init() anywhere.
I'm using:
Gallery versie = 2.1.1 core 1.1.0.1
PHP versie = 4.3.11 apache2handler
Web server = Apache/2.0.53 (Fedora)
Database = mysql 4.1.19, lock.system=flock
Toolkits = Gd
Versnelling = none, none
Besturingssysteem = Linux server9.hosting2go.nl 2.6.12-1.1381_FC3smp #1 SMP Fri Oct 21 04:03:26 EDT 2005 i686
Standaard thema = matrix
Talen = nl_NL
Browser = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; InfoPath.2)
function runGallery() {
require_once('scrapalbum/embed.php');
// if anonymous user, set g2 activeUser to ''
$uid = '';
// initiate G2
$ret = GalleryEmbed::init(array('g2Uri' => '/scrapalbum/','embedUri' => 'scrapgalerie.php','activeUserId' => $uid));
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;
}