Integrating zenphoto into WordPress

If you have a blog based on WordPress and you want to integrate zenphoto into that, you do that by creating a zenphoto theme that is based on your WordPress theme. I did that with my gallery and here's a description on how I did that.

In the zenphoto installation directory, there's a themes folder. Use one of these themes as a basis for your WordPress-like zenphoto theme by simply copying and renaming it and then activating it in zenphoto. A theme basically consists of its CSS, and the files index.php (the albumbs overview), album.php (an album with thumbnails), and image.php (for one single image). All these php files need to be touched in a similar way. I'll explain it for index.php.

The first line in index.php is

<?php if (!defined('WEBPATH')) die(); ?>

Keep that one - never remove it. After that line, add the following one to import all WordPress functions (and replace "/blog/" in the URL with the installation directory of WordPress in your web root):

<?php require($_SERVER['DOCUMENT_ROOT'].'/blog/wp-blog-header.php'); ?>

After this line, we tell the WordPress theme to include the CSS of the zenphoto theme:

<?php
// add the zen css to the wordpress header
function addcss() {
  global $_zp_themeroot;
  echo '<link rel="stylesheet" href="'.$_zp_themeroot.'/zen.css" type="text/css" />';
}
add_action('wp_head', 'addcss');
?>

Now, remove all stuff from DOCTYPE to the "main" DIV and replace it by the header code of your blog:

<?php get_header(); ?>
...

Simply copy&paste all necessary code from your existing WordPress theme up to the beginning of the "content" DIV. Don't include the "main-loop" part of the WordPress theme - but leave the "main" DIV of the zenphoto theme as it is.
After the "main" DIV is closed, close the WordPress "content" DIV and add the sidebar and the footer from your existing WordPress theme:

<?php get_sidebar(); ?>
<?php get_footer(); ?>

If you have WordPress and zenphoto use the same database on your machine, then your done. If not, you have to add two more lines to switch between the two databases you use. You do that by putting

<?php db_connect(); // reconnect to zenphoto db ?>

right before the beginning of the "main" DIV and

<?php $wpdb->select(DB_NAME); // reconnect wordpress db ?>

right after the end of the "main" DIV.

The final index.php of your new zenphoto theme will then look like:

<?php if (!defined('WEBPATH')) die(); ?>
<?php require($_SERVER['DOCUMENT_ROOT'].'/blog/wp-blog-header.php'); ?>

<?php
// add the zen css to the wordpress header
function addcss() {
  global $_zp_themeroot;
  echo '<link rel="stylesheet" href="'.$_zp_themeroot.'/zen.css" type="text/css" />';
}
add_action('wp_head', 'addcss');
?>

<?php get_header(); ?>
<?php db_connect(); // reconnect to zenphoto db ?>

<div id="content" class="narrowcolumn">
  <div id="main">
    put everything from the original zenphoto
    index.php "main" DIV here ...
  </div>
</div>

<?php $wpdb->select(DB_NAME); // reconnect wordpress db ?>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Follow the same steps for album.php and image.php and you are done.

I don't know if anyone else has noticed

I don't know if anyone else has noticed this but Ruzee hasn't responded to anyone in this thread for almost 2 years!

Jods - I just wrote about your (our) problem again in WP http://wordpress.org/support/topic/191483?replies=1 - let's work on it together and try to find a solution!

I had difficulty editing the

I had difficulty editing the Zenphoto theme, it kept throwing error messages to me.

What I did instead was change the page title field of my Wordpress gallery page to include an "a" tag to turn the title into a link. So, when someone comes to my website and clicks 'Gallery' they will be taken through to my zenphoto albums. I just gave the zenphoto page a similar look and feel to my main website. Nice easy alternative for those which are having problems with integrating zenphoto and wordpress :)

Check out what I did at www.ginajphotography.com

It does work

I do see Ruzee has not responded to any comments but his instructions does work great for wordpress integration. I have tried all the methods/hacks/plugins but this is the easiest way which provides total control over CSS/integration and performance
Many Thanks Ruzee!

visit: http://www.blackberrytune.com/photo/

How can I install the Plugin under

How can I install the Plugin under Wordpress 2.5

thanks for zenphoto theme tutorial,

thanks for zenphoto theme tutorial, very valuable =)

I have had some bugs in zended php

I have had some bugs in zended php files that prevented my site from running properly.

I finally found a program that can decompile the zended script. The website is for site owners who have lost their source code.

http://www.decode-zend-decoder.com

Hope this helps someone who is stuck like I was.

hey! a question, does anyone get this

hey!
a question, does anyone get this message when trying to follow the instructions above:
Fatal error: Cannot redeclare class streamreader in /......./wp-includes/streams.php on line 32
I would appreciate any help! thanks for sharing how you integraded wordpress with zenphoto.
thanks

I'm getting the same problem

I'm getting the same problem with Plogger Gallery Manager !

Cannot redeclare class StreamReader in ...

Do we have to change the class name ?

There's sort of a problem here.

There's sort of a problem here. zenphoto still isn't being recognized by WordPress, so whenever someone views your gallery - they can see it just fine. However, a "silent" 404 error is being sent in the response headers. So spiders won't index it.

Response Headers - http://www.ruzee.com/photos/

Date: Mon, 09 Jun 2008 04:29:55 GMT
Server: Apache/2.2.3 (Ubuntu) PHP/5.2.1 mod_ssl/2.2.3 OpenSSL/0.9.8c
X-Powered-By: PHP/5.2.1
Set-Cookie: bb2_screener_=1212985795+68.145.216.220; path=/blog/
X-Pingback: http://www.ruzee.com/blog/xmlrpc.php
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Last-Modified: Mon, 09 Jun 2008 04:29:55 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

404 Not Found

There are 3 kinds of people in this

There are 3 kinds of people in this world.
People that make things happen! :)
People that watch things happen...and
Those poor souls that wonder what happened
http://www.thousanddollarprofits.com/103010

[...] I add a photo gallery to the

[...] I add a photo gallery to the site, using ZenPhoto 1.1 which is a create piece of software. Not only is it very easy to use but it has some great templates if it were being used as a standalone version. I had some trouble integrating zenphoto in wordpress but found a great plugin for single Sign-On of both wordpress and zenphoto. Thanks must also go to Steffen Rusitschka for his ‘Integrating zenphoto in wordpress’guide. [...]

Hi I just wanted to say thank you very

Hi
I just wanted to say thank you very much for this great tutorial..
I've been searching for a way to do this weeks ago..
By the way, integrating zen with wordpress is much better than using nexgen gallery plugin only, although nexgen gallery is good for simple galleries with small image sizes.

The next gen gallery will do

The next gen gallery will do ok.....

you shuld try using next gen gallery

you shuld try using next gen gallery from wordpress website

sorry, forgot email. admin (at)

sorry, forgot email. admin (at) liveimagephoto.com no spaces.

although i managed to fix my problem by just not calling up wp-footer at all on the zenphoto gallery pages. is there anything u can figure out by this information? apparently its something with closing the footer but still displays the internal css of ZP on external WP pages. perhaps after the /div needs a php endif?

thank you so much for this script, it

thank you so much for this script, it integrates very well well with my page.

Im having a CSS issue though, its where the wordpress sidebar is displayed with the H2,H3,H4,H5 from zenphoto's CSS and those seem the only css styles being ported to the sidebar. is there a way i can call up the wp theme CSS right before on your code?

thanks, and check out my site www.liveimagephoto.com zenphoto handles ALL images.

Thank you, thank you. Wonderful trick.

Thank you, thank you. Wonderful trick. Really works.

I like your blog theme. I want to use

I like your blog theme. I want to use it on my blog.
Can you please tell me from where I can download these theme?

Many thanks

--------------------------------------------------------------------------------
Dan owner of the future gadgets blog future gadgets and inventions

What happens when you want to include

What happens when you want to include the Zenphoto Rss feed, as well as the javascript files that may be there?

thank you for

thank you for sharing
-----------------------------------
tuyen dung | viec lam | tim viec

[...] will run in parallel rather than

[...] will run in parallel rather than in unison.  So I continued searching the web until I stumbled on this article from Ruzee.com on how the author integrated ZP into his own [...]

I have been a frequent visitor of this

I have been a frequent visitor of this blog for some time now, so I thought it would be a good idea to leave you with my thanks.

Regards,
Jim Mirkalami

Simply copy&paste all

Simply copy&paste all necessary code from your existing WordPress theme up to the beginning of the "content" DIV. Don't include the "main-loop" part of the WordPress theme - but leave the "main" DIV of the zenphoto theme as it is.
After the "main" DIV is closed, close the WordPress "content" DIV and add the sidebar and the footer from your existing WordPress theme:

It does work

I do see Ruzee has not responded to any comments but his instructions does work great for wordpress integration. I have tried all the methods/hacks/plugins but this is the easiest way which provides total control over CSS/integration and performance

visit: http://www.blackberrytune.com/photo/

It works great

I do see Ruzee has not responded to any comments but his instructions does work great for wordpress integration. I have tried all the methods/hacks/plugins but this is the easiest way which provides total control over CSS/integration and performance
Many Thanks Ruzee!

visit: http://www.blackberrytune.com/photo/

It works great

I do see Ruzee has not responded to any comments but his instructions does work great for wordpress integration. I have tried all the methods/hacks/plugins but this is the easiest way which provides total control over CSS/integration and performance
Many Thanks Ruzee!

visit: http://www.blackberrytune.com/photo/

It works great

I do see Ruzee has not responded to any comments but his instructions does work great for wordpress integration. I have tried all the methods/hacks/plugins but this is the easiest way which provides total control over CSS/integration and performance
Many Thanks Ruzee!

visit: http://www.blackberrytune.com/photo/

good information.

Your link has been very helpful and informative.

404 silent header problem for search engine spiders

If you want to have indexed pages in google, add 1 string after:

<?php require($_SERVER['DOCUMENT_ROOT'].'/wp-blog-header.php'); ?>
<?php header("HTTP/1.1 200 OK");?>

I've found this at http://www.zenphoto.org/support/topic.php?id=252
it works!

Pingback

[...] способ интеграции Zenphoto в Wordpress описан у Ruzee и внешне вроде все хорошо работает за исключением [...]