I've managed to work the zenphoto gallery into and pre-designed site that I work on. I had to modify a lot of the text by commenting out "header" lines or replacing "header" with function because I was getting a lot of "Cannot modify header" errors because I call a separate php page for my header. I've almost got it working, but I'm still getting an error message after submitting a comment. The comment still goes through and reloads the page but I get this message:
Warning: Cannot modify header information - headers already sent by (output started at /mnt/gs01/herd02/8945/domains/neworleansblack.com/html/_head3.php:9) in /mnt/gs01/herd02/8945/domains/neworleansblack.com/html/photogallery/zp-core/functions-controller.php on line 136
Any thoughts as to how to fix this without losing any important function?
Here is the function around line 136 in my current "functions-controller.php" script:
function zp_handle_comment() {
global $_zp_current_image, $stored, $error;
if (isset($_POST['comment'])) {
if (in_context(ZP_IMAGE) && isset($_POST['name']) && isset($_POST['email']) && isset($_POST['comment'])) {
if (isset($_POST['website'])) $website = strip_tags($_POST['website']); else $website = "";
$commentadded = $_zp_current_image->addComment(strip_tags($_POST['name']), strip_tags($_POST['email']),
$website, kses($_POST['comment'], getOption('allowed_tags')));
if ($commentadded == 2) {
unset($error);
if (isset($_POST['remember'])) {
// Should always re-cookie to update info in case it's changed...
$info = array(strip($_POST['name']), strip($_POST['email']), strip($website));
//LINE 136---> setcookie('zenphoto', implode('|~*~|', $info), time()+5184000, '/');
} else {
setcookie('zenphoto', '', time()-368000, '/');
}
// Redirect to this image page to prevent re-submission.
return('Location: ' . FULLWEBPATH . '/' . zpurl());
exit;
} else {
$stored = array($_POST['name'], $_POST['email'], $website, $_POST['comment'], false);
if (isset($_POST['remember'])) $stored[3] = true;
$error = 1 + $commentadded;
}
}
} else if (isset($_COOKIE['zenphoto'])) {
// Comment form was not submitted; get the saved info from the cookie.
$stored = explode('|~*~|', stripslashes($_COOKIE['zenphoto'])); $stored[] = true;
} else {
$stored = array('','','', false);
}
return $error;
}
Comments
http://www.neworleansblack.com/photogallery/
Try to comment on a photo to see what I'm talking about.
You're getting the error because in order for the header() calls to work, there can't be anything printed (not even included PHP files) before the call.
That's fairly common for any web application, especially ones with form posts, like comment forms -- you can't just include them into any PHP file, even though you've done a good job of it so far.
For Zenphoto, we generally recommend using a theme to render the design of the gallery, instead of putting the gallery inside a wrapper. It works better if everything's done through Zenphoto for Zenphoto's pages. And it's not that much harder -- just put your header and footer in the theme files instead of outside zenphoto.
The way you've done it may still work though -- it will just be harder to get comments working, and you'll notice other small problems as well, but nothing too big. Good luck.
I actually tried that first, but it was screwing up my css because some of the classes were the same. But I think I just figured out how to fix that. Gotta go. Thanx.