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.
October 15th, 2006 at 6:14
What about zenJavascript();?
October 17th, 2006 at 12:26
Hi, This is great How-To! it worked perfektly for me.
but maybe you could give me a hint, I’m trying to include my zenphoto gallery into the main navigation, like you did… but i really have no idea how.
Is ist something like the links_to plugin? - or is there another way to do this?
greetings
tom
October 22nd, 2006 at 11:03
@joshuasbones: ?
@tom: well, in my case, it’s simply a relative static link: <a href=”/photos”>…</a>…
October 29th, 2006 at 18:07
thanks a lot! worked for me! lotsa css editing though! how i wish someone would develop a plugin for this =)
October 31st, 2006 at 7:31
I’ve tried this…. but REALLY having a hard time with the CSS adjustments… it is really not clear how to adjust the width of Zen Photos. Can you please assist?
I am trying it at http://www.naijamd.com/photos
Thanx again and have a good day
November 10th, 2006 at 23:09
[...] La integración con Wordpress no dio mucho trabajo y hay dos tutoriales muy buenos que enseñan como hacerlo. El método “oficial” del foro de soporte de Zenphoto y el publicado por Steffen Rusitschka en Ruzee.com. [...]
November 14th, 2006 at 1:36
@preckie, Mas: Yeah, I know, but a plugin is kind of hard to do unless both projects work together on this issue. Until then, the walk-through given is one possible solution - and yes, you need to know a bit about CSS, PHP, and stuff if you have a non-standard theme…
November 14th, 2006 at 19:08
Hi,
great work you did, works perfekt on index.php BUT - neither on album.php nor image.php .
I’ use the Zenphoto testin theme and tried nearly all possibilities. I also used different themes but I get a blank page I think at the point I paste []
yes I changed my blog directory.
Could somebody email me his album.php with a completely working get_header? Would be so great
kontakt [at] sandrostark.de
November 16th, 2006 at 17:47
[...] http://www.ruzee.com/blog/2006/06/integrating-zenphoto-into-wordpress/ [...]
January 9th, 2007 at 6:08
@Sandro
I am having the same problem, it worked fine on the index and image pages but I cannot get it to work on the album.php page, these are the results:
http://www.dremeda.com/zenphoto/testing-2/
If anyone has any ideas please let me know.
Other than that this has been a great tool to integrate, I think once the bug is worked out this will look great!
< Prev 1 … 2 3 4 … 9 Next > Show All
Leave a Reply