Integrating ZenPhoto in Wordpress

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
«1

Comments

  • Put the following information in your zproot/index.php

    /* 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.
  • I didn't think you were being a jerk at all. Sorry that you thought I thought that. : -)

    Thanks for the instructions above. I'll give them a try.

    spellmank
  • I hate to appear dim, but I'm not finding require_once('zen/template-functions.php'); or require(..wp-blog-header.php) in any of my theme/default files or zen/ files for that matter. Not sure how to edit those theme/default files if I can't find the "calls" you mentioned above. I'm very new to PHP so some I am a bit lost.

    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
  • All files that you edit are going to be zenphoto files.

    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.
  • I'm getting this fatal error:

    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?
  • Did you do this fix?

    4. Work around a conflict with comments by opening the ZP template image.php and replacing isset($error) with $FIXME.
  • I had already done that. I replaced iseet($error) which looked like this (isset($error)) with this ($FIXME).
  • copy and paste your zproot/index.php into here so I can see..

    also, do you have a link we can look at?
  • trisweb Administrator
    It's a conflict in the function name since I copied that function from WP ;-) Just rename it and its one use in Zenphoto and it should work. Sorry about that, how bout if I rename the function for the next release?
  • trisweb,

    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

  • <?php
    /* Original Code */
    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");
    }

    /* Start Wordpress */
    define('WP_USE_THEMES', false);
    require($_SERVER["DOCUMENT_ROOT"].'/wordpress/wp-blog-header.php');
    /* Start zenphoto */
    require_once("zen/template-functions.php");
    getheader();
    getsidebar();
    $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");
    }

    ?>

    Link: http://www.karaspellman.com/wordpress/zenphoto/
  • I am sorry, I made a grammitical error.. dont put the code above into your index.php.. replace the old code with the code above.

    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();

    ?>`
  • Hi,

    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>
  • Here is that email error again:

    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));
    }
  • trisweb Administrator
    I told you above, you have to rename is_valid_email in zenphoto. It will not work without doing that. Just replace the string "is_valid_email" anywhere it's found in ZP code to "is_valid_email_zp"

    It's changed in the latest SVN if you just want to use that...
  • Sorry, trisweb,

    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
  • ruzee Member
    Here's another way of doing it (including a nice howto):
    http://www.ruzee.com/blog/2006/06/integrating-zenphoto-into-wordpress/
  • webdev Member
    thnx ruzee !
  • ny888 Member
    I'm so close to getting this all to work I can taste it but need some clarification -

    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 ??
  • you are most likely not missing edits just styling problems.

    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.
  • can anyone please help me :(
    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
  • thanks it worked
  • my zenphoto integration was a success, thanks to ruzee! http://shadesofblack.free1k.com/zenphoto/ i used the 'testing' theme that came in with the zenphoto package and edited the css.
  • My image.php page automatically sends a warning 'There was an error submitting your comment. Name, a valid e-mail address, and a comment are required.' I'm running the latest version of zenphoto (1.0.8.2), so there's no function name conflict with is_valid_email. I've integrated wordpress with zenphoto as per Ruzee's method.

    For example:

    http://hl.strangerpixel.com/techniques/beading/beading+006.jpg.php

    Thanks
  • gekow Member
    The integration worked well for me and it looks quite good ( gekow.net/zenphoto/ ) but what doesn't work is the breadcrumb navigation (made by Breadcrumb Navigation XT plugin) nor is the gallery shown in the page title.

    Any idea?
  • Luigino Member
    hello precious and chilifrei64... I'm trying to set up the sidebar_right positioned at his place and not under the content of zenphoto and I worked that out with ruzee method.... so I'm here asking you how did you settled up the css so we can have the sidebar_right at his right position?.... thanks!
    p.s.: I have WP 2.2 + Jide Freshy 2.0 Preview theme...

    Ciao, Luigi
  • I managed to get it working thanks to ruzee tutorial..thanks ruzee!!!

    www.bertsimons.nl/zenphoto
  • Anya Member
    Hi all,

    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!
  • acrylian Administrator, Developer
    That is because the bloginfo() function of wordpress is unknow to zenphoto. It should work if you delete that part.
    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...:-)
Sign In or Register to comment.