14 Jan, 2009 in Programming by

Plogger is a great PHP open source image gallery to hack up!

;

Say you’ve got an artist friend or two that wants a website to display all their great artwork.

Along with that, they want a custom site template, not just a standard image gallery.

Well Plogger is a great tool for just such an occasion! This light weight image cms installs in seconds only needing a few parameters.

After it’s installed, you can use some custom coding to easily pull thumbnails & photos out of your managed database to display on your artist friends website.

<?php 
include("plogger/gallery.php");
include("plog-functions.php");
include("plog-globals.php");
 
function get_gallery($collectionId = 1, $albumId) {
        $sql = "select * from plogger_pictures where parent_collection = " . $collectionId . " and parent_album = " . $albumId;
        $result = run_query($sql);
 
        while ($row = mysql_fetch_assoc($result)) {
                $id = $row["id"];
                $thumbUrl = "/plogger/thumbs/$id-".basename($row["path"]);
                $largeUrl = "/plogger/thumbs/lrg-$id-".basename($row["path"]);
                $caption = $row["caption"];
 
                echo "<a href='$largeUrl' rel='lightbox' title='" . $caption . "'><img src='" . $thumbUrl . "' alt='" . $caption . "'></a>";
        }
}
 
?>

In this example, I’ve installed Plogger in the /plogger/ directory. Include this code in your PHP cms then you can call:

<?php get_gallery(1, x) ?>

to include a specific album on a web page. Where ‘x’ is the album number you want to load. You can find this by mousing over the the album links, after you’ve created them, in Plogger.

You may notice that this sample is also using Lightbox to make the thumbnails come to life when clicked adding a more professional touch to the site. So make sure you have that installed or remove the “rel=’lightbox’” attribute.

It’s easy to batch upload your photos into Plogger which will bring your new gallery pages to life! The other great this about this is, you can put your artist friends in charge of updating their own website images! It’s so easy to do, they’ll be glad to have you as a friend!

Share on Twitter

2 Responses so far | Have Your Say!

  1. Wavatar

    Fox Hysen  |  March 24th, 2011 at 9:22 am #

    hello! this seems brilliant…I’m a php novice and dont know where to stick in the code…have tried directly into my index.php but that does not seem to work…
    more details would be fantastic! thanks so much!

  2. Wavatar

    Roger  |  March 25th, 2011 at 2:02 pm #

    Hi Fox! Okay, this code assumes that your plogger is installed in a subdirectory of your main site. Then you need to copy all the sample code for the “get_gallery” function to your index page. Then to actually display the gallery, call the “get_gallery(x,x)” function with the parameters of your Plogger albums. Those values just depend on the albums you have created. HTH