G2 integration in my website

Zeoi

Joined: 2005-11-06
Posts: 2
Posted: Sun, 2005-11-06 18:01

Dear All,

I have integrated G2 in my website without any problems - I Thought!

The website works like a charme unless I hit the "gallery >> Ireneleden" navigation:
An error occur like:

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/album2/index.php:2) in /var/www/html/album2/modules/core/classes/GalleryPhpVm.class on line 124

My code is

Quote:
$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('embed.php');

$data = array();

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

// initiate G2
$ret = GalleryEmbed::init(array('embedUri' => 'index.php',
'embedPath' => '/album2',
'relativeG2Path' => '/',
'loginRedirect' => '/index.php',
'activeUserId' => $uid));
if (!$ret->isSuccess()) {
$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 */
if (!empty($javascript)) {
foreach ($javascript as $script) {
$data['javascript'] .= "\n".$script;
}
}

/* Add G2 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;

include("header.php");

print $data['headHtml'];
print $data['bodyHtml'];
include("footer.php");
}

?>

An example you can see at http://www.portfolioplein.nl/album2/index.php
Hope somebody had the same problem and a solution :)

Thank you in advance for your help

With Kind regards,

Zeoi

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-11-06 18:51

as it says, output starts at line 2 of your index.php file.
you shouldn't output anything, no html, nothing, before the if ($g2data['isDone']) { exit; } check.

make sure config.php has no newline / space after the closing
?>
also make sure you have no lines before <?php or after ?> in your index.php

 
Zeoi

Joined: 2005-11-06
Posts: 2
Posted: Sun, 2005-11-06 19:06

Thank you Valiant,

I do not no why,but I always start(ed) at line 2 with <?php
I replaced it and it works - thank you