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.
Hi, the name's Steffen and I'm writing about the Web, programming
and all those things coming to my mind. Enjoy your stay.
March 29th, 2008 at 17:08
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.
April 3rd, 2008 at 0:16
[...] 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. [...]
April 20th, 2008 at 9:57
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
June 9th, 2008 at 6:33
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
June 18th, 2008 at 10:30
If you suspect someone’s been lying to you about
home business opportunities, guess what?
You’re absolutely right! Get The Truth Here:
http://ols387.grnteambuilder.com
June 19th, 2008 at 12:47
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
June 25th, 2008 at 19:21
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.
June 27th, 2008 at 16:04
thanks for zenphoto theme tutorial, very valuable =)
June 29th, 2008 at 23:22
שיש,שישלמטבח,שיש למטבחים
June 30th, 2008 at 9:10
Thank You. I found it to very informational, it will certainly provide help in programming.
< Prev 1 … 7 8 9 Show All
Leave a Reply