Hi,
What is the best method to integrate ZenPhoto within WordPress? I've looked into ZenPress (
http://simbul.bzaar.net/zenpress/), but it appears that it only allows for linking to one's separate ZenPhoto site. I like the way A day in the life... site (
http://www.chilifrei.net) has integrated ZenPhoto in such a way that it looks like the rest of the site. Any assistance would be greatly appreciated.
Thanks,
spellmank
Comments
/* Start Wordpress */
define('WP_USE_THEMES', false);
require($_SERVER["DOCUMENT_ROOT"].'/journal/wp-blog-header.php');
/* Start zenphoto */
require_once("zen/template-functions.php");
$themepath = 'themes';
$theme = $_zp_gallery->getCurrentTheme();
$_zp_themeroot = WEBPATH . "/$themepath/$theme";
if (in_context(ZP_IMAGE)) {
include("$themepath/$theme/image.php");
} else if (in_context(ZP_ALBUM)) {
include("$themepath/$theme/album.php");
} else if (in_context(ZP_INDEX)) {
include("$themepath/$theme/index.php");
}
3. Tweak your zenphoto templates (not your wp templates) to fit your wp style. You can now use functions such as get_header and get_sidebar.
4. Work around a conflict with comments by opening the ZP template image.php and replacing isset($error) with $FIXME.
A couple of things to look for
if you are calling your wordpress
getheader();
or
getsidebar();
That can cause problems depending on where it is placed.
make sure your
require_once('zen/template-functions.php');
is before your getheader() or getsidebar() calls and right after your require(..wp-blog-header.php) call
The other thing that I did because of conflicting css styles was I removed the zenphoto css file from the templates and merged it into my wordpress theme css file. This made integrating much easier.
PS.. I wasnt trying to be a jerk on my board.. sorry if I came across that way, I thought you were asking questions about zenpress which I dont know much about other than I have it installed and it works for me.
Thanks for the instructions above. I'll give them a try.
spellmank
However, I was able to edit the zproot/index.php and the image.php files successfully. I'm holding off on the css edits until I figure out how to edit the ZP templates.
spellmank
the require_once('zen/template-functions.php'); is located in your zenphoto root This is the file(really the only file) that you need to edit. NOT the index.php in your themes directory.
example:(my website) www.chilifrei.net/zp
is the url to my gallery. On my hard drive the path is d:\websites\chilifrei.net\zp
inside that zp folder is an index.php which is the file you need to edit.
Fatal error: Cannot redeclare is_valid_email() (previously declared in /var/www/vhosts/karaspellman.com/httpdocs/wordpress/zenphoto/zen/functions.php:88) in /var/www/vhosts/karaspellman.com/httpdocs/wordpress/wp-content/plugins/email/email.php on line 270
Any thoughts?
4. Work around a conflict with comments by opening the ZP template image.php and replacing isset($error) with $FIXME.
also, do you have a link we can look at?
Ahhh, so I shoul rename isset($error) something like $Oops?
Sorry, don't quite follow you. I don't know enough about PHP yet.
spellmank
Link: http://www.karaspellman.com/wordpress/zenphoto/
you should only have your second part.. it looks as if you have both the original code and the new code live and between php brackets? your zproot/index.php should look like this
`<?php<br />
/* Start Wordpress */
define('WP_USE_THEMES', false);
require('../wp-blog-header.php');
require_once("zen/template-functions.php");
//Get Header */
get_header();
//Get Sidebar
get_sidebar();
/* Start zenphoto */
$themepath = 'themes';
$theme = $_zp_gallery->getCurrentTheme();
$_zp_themeroot = WEBPATH . "/$themepath/$theme";
if (in_context(ZP_IMAGE)) {
include("$themepath/$theme/image.php");
} else if (in_context(ZP_ALBUM)) {
include("$themepath/$theme/album.php");
} else if (in_context(ZP_INDEX)) {
include("$themepath/$theme/index.php");
}
//Get Footer
get_footer();
?>`
I'm still getting that email error after making the changes to the index.php file above. Here is my code for the image.php from the default theme. Again I had changed isset($error) to ($FIXME). Should it be just $FIXME instead of ($FIXME)?
<?php if (!defined('WEBPATH')) die(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title><?php printGalleryTitle(); ?> | <?php echo getAlbumTitle();?> | <?php echo getImageTitle();?></title>
<link rel="stylesheet" href="<?php echo $_zp_themeroot ?>/zen.css" type="text/css" />
<script type="text/javascript">
function toggleComments() {
var commentDiv = document.getElementById("comments");
if (commentDiv.style.display == "block") {
commentDiv.style.display = "none";
} else {
commentDiv.style.display = "block";
}
}
</script>
<?php zenJavascript(); ?>
</head>
<body>
<div id="main">
<div class="imgnav">
<?php if (hasPrevImage()) { ?>
<div class="imgprevious">" title="Previous Image">« prev</div>
<?php } if (hasNextImage()) { ?>
<div class="imgnext">" title="Next Image">next »</div>
<?php } ?>
</div>
<div id="gallerytitle">
<h2><span>" title="Gallery Index"><?php echo getGalleryTitle();?>
| " title="Gallery Index"><?php echo getAlbumTitle();?>
| </span> <?php printImageTitle(true); ?></h2>
</div>
<div id="image">
" title="<?php echo getImageTitle();?>"> <?php printDefaultSizedImage(getImageTitle()); ?>
</div>
<div id="narrow">
<?php printImageDesc(true); ?>
<div id="comments">
<?php $num = getCommentCount(); echo ($num == 0) ? "" : ("<h3>Comments ($num)</h3>"); ?>
<?php while (next_comment()): ?>
<div class="comment">
<div class="commentmeta">
<span class="commentauthor"><?php printCommentAuthorLink(); ?></span> says:
</div>
<div class="commentbody">
<?php echo getCommentBody();?>
</div>
<div class="commentdate">
<?php echo getCommentDate();?>
,
<?php echo getCommentTime();?>
<?php printEditCommentLink('Edit', ' | ', ''); ?>
</div>
</div>
<?php endwhile; ?>
<div class="imgcommentform">
<!-- If comments are on for this image AND album... -->
<h3>Add a comment:</h3>
<form id="commentform" action="#" method="post">
<div><input type="hidden" name="comment" value="1" />
<input type="hidden" name="remember" value="1" />
<?php if ($FIXME) { ?><tr><td><div class="error">There was an error submitting your comment. Name, a valid e-mail address, and a comment are required.</div></td></tr><?php } ?>
<table border="0">
<tr>
<td><label for="name">Name:</label></td>
<td><input type="text" id="name" name="name" size="20" value="<?php echo $stored[0];?>" class="inputbox" />
</td>
</tr>
<tr>
<td><label for="email">E-Mail:</label></td>
<td><input type="text" id="email" name="email" size="20" value="<?php echo $stored[1];?>" class="inputbox" />
</td>
</tr>
<tr>
<td><label for="website">Site:</label></td>
<td><input type="text" id="website" name="website" size="40" value="<?php echo $stored[2];?>" class="inputbox" /></td>
</tr>
</table>
<textarea name="comment" rows="6" cols="40"></textarea>
<input type="submit" value="Add Comment" class="pushbutton" /></div>
</form>
</div>
</div>
</div>
</div>
<div id="credit"><?php printAdminLink('Admin', '', ' | '); ?>Powered by zenphoto</div>
</body>
</html>
Fatal error: Cannot redeclare is_valid_email() (previously declared in /var/www/vhosts/karaspellman.com/httpdocs/wordpress/wp-content/plugins/email/email.php:270) in /var/www/vhosts/karaspellman.com/httpdocs/wordpress/zenphoto/zen/functions.php on line 88
I took a look at line 88 in the ZenPhoto functions.php and it is this:
// Determines if the input is an e-mail address. Stolen from WordPress, then fixed.
function is_valid_email($input_email) {
$chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i";
if(strstr($input_email, '@') && strstr($input_email, '.')) {
if (preg_match($chars, $input_email)) {
return true;
}
}
return false;
}
I also looked at line 270 from email.php in WordPress:
### Function: Check Valid E-Mail Address
function is_valid_email($email) {
$regex = '/^[A-z0-9][\w.-]*@[A-z0-9][\w\-\.]+\.[A-z0-9]{2,6}$/';
return (preg_match($regex, $email));
}
It's changed in the latest SVN if you just want to use that...
I'm new to PHP so I don't always follow what has been said above. When you said to rename a function I wasn't sure which one. I just needed more specifics.
Thanks again for your help!
spellmank
http://www.ruzee.com/blog/2006/06/integrating-zenphoto-into-wordpress/
I've modified index.php so now it displays with my header, sidebar, and footer.
Only thing is that the zp content is not fitting inside of the blog alongside the sidebar. Instead, it's displaying below the sidebar and is taking up the width of the page.
I must be missing edits ??? in index.php, album.php and image.php ??
for starters.. (and I am not sure what your theme looks like) but if you need to make sure your sized are correct. if all your content in wordpress is displayed in say a 700px container and have a 200px sidebar.. that only leaves you with 500px for your gallery which the default image is 595px.. so that will cause this to happen.
depending on how you r theme was styled.. you may need to change the sidebar to float:left(or right) and change the gallery to float:right(or left) so that you dont end up with what you are describing.
I can tell you from personal experience (I had the same problem that you are explaining) was I just added the zp stylesheet to my wp stylesheet piece by piece because of conflicting tags with my theme.
http://www.nuttyfamily.com/wp/wp-content/themes/mesozoic-20/style.css
I followed the methods and it kind of worked, but I am unble to edit the css file
please check it at http://www.adidap.com/gallery
thanks
For example:
http://hl.strangerpixel.com/techniques/beading/beading+006.jpg.php
Thanks
Any idea?
p.s.: I have WP 2.2 + Jide Freshy 2.0 Preview theme...
Ciao, Luigi
www.bertsimons.nl/zenphoto
I'm in the mist of converting my site into Wordpress, but I love Zenphoto and don't want to give it up, so I've been playing around with integrating it into my WP. Last night I tried this via the Ruzee method suggested above. I thought that the walkthrough was very well written and clear, but I'm getting an error now that I can't figure out how to address:
`Fatal error: Call to undefined function bloginfo() in /home/.username/accountname/domain/wordpress/wp-content/themes/version03/header.php on line 4`
This line in the Wordpress header reads:
`; charset=<?php bloginfo('charset'); ?>" />`
Any idea what I can do to address this? I deleted the line to see what would happen, but ZP simply found the next instance of "php bloginfo..." and gave me the same error, four lines down.
I'm using WP 2.5.1, ZenphotoPress 1.4, and Zenphoto 1.0.8. Thanks so much for any help in advance! I'm new to the whole WP thing, but I love ZP and don't want to give it up!
I have never used that version (I always went the build a look-alike-theme for zenphoto way), but you might try to look here, which is a somehow related solution (the random images stuff is just an example):
http://www.zenphoto.org/2008/01/hacks/#zenphoto-as-plugin
PS: You really should consider to upgrade zenphoto...:-)