Integration with existing sites and other CMS

    This is not really possible as Zenphoto is actually a standalone CMS of its own. Technically, these are the recommended ways to "integrate" Zenphoto with another CMS:

    Match the look of your Zenphoto site to your existing site

    This basically means to create a theme for your Zenphoto site to make it look like your existing site. For example by re-using HTML and CSS from it. Also please review our theming tutorial.

    For WordPress specifially there are techniques available collected here:
    https://www.zenphoto.org/news/integrating-zenphoto-into-wordpress-tutorials 
    For Wordpress specifially there are some third party Wordpress tools available.

    Or maybe you want to run your entire site with Zenphoto using the CMS plugin Zenpage.

    Zenphoto as a "plugin"

    This is a more advanced way to achieve that. You can use zenphoto features in your main web pages by including template-functions.php in your php pages. The following is an example of this technique. (The example assumes zenphoto is installed in a folder named zenphoto):

    <?php 
    /*
    * This script is an example of how to use Zenphoto content from a Non-Zenphoto WEB page.
    * You must define SERVERPATH and WEBPATH to correctly point at the Zenphoto installation.
    * Here we are presuming that the running script is in the root of the WEBsite and the
    * Zenphoto installation is in a folder named "zenphoto" within that root folder.
    */
    define('SERVERPATH',str_replace('\\','/',dirname(__FILE__)).'/zenphoto');
    define('WEBPATH','/zenphoto');
    /*
    * Now we "include" the Zenphoto template functions. This will instantiate the Zenphoto installation
    * and make all theme functions available to us.
    */
    require_once(SERVERPATH.'/zp-core/template-functions.php'); ?>
    <!DOCTYPE html>
    <head>
    </head>
    <body>
    <p>This example will show a pre-defined image. Really, almost any theme related actions could be done here.</p>
    <?php
    /*
    * Instantiate an image and make it the current image
    */
    $albumName = 'test_album/lesser-three-gorges';
    $imageName = '2007-05-03-182646_sjb.jpg';
    $image = newImage(NULL, array('folder'=>$albumName,'filename'=>$imageName));
    makeImageCurrent($image);
    /*
    * Show the image sized to "500"
    */
    printCustomSizedImage(getImageTitle(), 500); ?>
    <!-- provide a link to the Zenphoto gallery -->
    <p><a href="<?php echo WEBPATH; ?>">Visit the actual gallery from which this image was extracted.</a></p>
    </body>
    </html>

    Note: Zenphoto makes use of global variables that are setup by the template functions load. This technique will NOT work if the require_once statement is done from within a function definition. Unfortunately WordPress and perhaps other application invoke their plugins from within functions, so invalidate this approach.

    Many of the zenphoto template-functions operate on $_zp_current_album, $_zp_current_image, and $_zp_gallery. The first two are referred to as the current album and current image in the function documentation (see below.) These variables normally are setup by the process of loading the root index.php file and proceding to your theme php file. They will NOT be setup automatically for you when you use zenphoto as a plugin. You can use the functions zp_load_gallery(), zp_load_album($folder), and zp_load_image($folder, $filename) to set these variables. $folder is the path from the album folder to the album. $filename is the name of the image within $folder.

    For further details on the template functions visit the Zenphoto Functions Guide.

    Creative Commons LicenseThis text by www.zenphoto.org is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

    Code examples are released under the GPL v2 or later license

    For questions and comments please use the forum or discuss on the social networks.

    Related items