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.
August 18th, 2006 at 20:24
[...] ????WORDPRESS???????????????????? ZENPHOTO??????????????? ???????????? ????????????????? WORDPRESS??????????????????? ?????????????? http://www.ruzee.com/blog/2006/06/integrating-zenphoto-into-wordpress/ [...]
September 11th, 2006 at 6:15
Hey man, this is an excellent write-up. I am really glad for it. This has made my ZenPhoto & Wordpress intergration very tight.
September 15th, 2006 at 19:37
Thanks!! worked like a charm! any ideas on login integration??
September 18th, 2006 at 1:46
[...] Faz algum tempo que eu vinha pensando em gastar umas horas para fazer a integração do zenphoto com o Wordpress utilizando o tutorial do Steffen Rusitschka Integrating zenphoto into Wordpress. Era estranho olha o blog, abrir as galerias de fotos e ter um visual completamente diferente. Ficava a impressão de que era outro site. [...]
September 19th, 2006 at 18:08
[...] recommandations suivantes pour intégration dans Wordpress. [...]
September 21st, 2006 at 1:21
Thanks for this tutorial. It made my integration about a thousand times easier. My galleries aren’t live yet, but I now know that they can look the way I want them to. Thanks again.
September 27th, 2006 at 3:05
[...] And if you want to build Zenphoto into wordpress there’s an excellent guide at ruzee.com. [...]
October 5th, 2006 at 20:10
Think someone could help me? I cant seem to get the sidebar where it belongs!
October 11th, 2006 at 22:55
Hi, thanks for your tutorial.
I made the change to my website and it’s good …
well expect something, my header change a little bit after in Zenpress page.
just have a look there:
main page wordpress:
http://www.jelto.net/blog/
main page zenpress:
http://www.jelto.net/blog/zp/
so does anyone knows where i’ve to change something ? !
Thanks.
October 12th, 2006 at 22:51
[...] En suivant les conseils de ruzee.com. Tags [...]
< Prev 1 2 3 … 9 Next > Show All
Leave a Reply