Latest Images Outside Zen Directory

Hello Everyone,

I am trying to insert the latest 3 images added to my album to my /index.php
zenphoto resides in /album/
Therefore, the latest images will be displayed OUTSIDE zen.

Can someone provide me with a correct script where I can accomplish that?

Thanks :)

Comments

  • look at http://www.zenphoto.org/trac/wiki/ZenphotoHacks#zenphotoasaplug-in for how to use zenphoto outside its realm. Look at the stopdesign theme's index.php file for how to get the latest images.
  • Thanks for reply and your time sbillard.
    I am PHP Newbie, sorry if I misunderstanding something incorrectly, I am receiving the following error

    Fatal error: Cannot redeclare printlatestimages()

    Using the following script
    `

    <?php<br />
    define('ZENFOLDER', 'album/zp-core');

    define('WEBPATH', '');

    require_once(WEBPATH . "" . ZENFOLDER . "/template-functions.php");

    function printLatestImages($number) {

    $images = query_full_array("SELECT images.albumid, images.filename

    AS filename, images.title AS title, albums.folder AS folder FROM

    ".prefix('images')." AS images, ".prefix('albums')." AS albums WHERE

    images.albumid = albums.id AND images.show = 1 ORDER BY images.id DESC LIMIT

    $number");

    $size =

    '_'.getOption('thumb_size').'_cw'.getOption('thumb_crop_width').'_ch'.getOpti

    on('thumb_crop_height');

    foreach ($images as $image) {

    $filename = $image['filename'];

    $album = $image['folder'];

    $desc = $image['title'];

    echo '

    ';

    if (getOption('mod_rewrite') == false) {

    echo '
    href="'.WEBPATH.'/index.php?album='.$album.'&image='.$filename.'"

    title="'.$desc.'">';

    } else {

    echo '

    title="'.$desc.'">';

    }

    /* echo 'image
    src="'.WEBPATH.'/cache/'.$album.'/'.$filename.$size.'.jpg">'; */

    echo 'image
    src="'.WEBPATH.'/zen/i.php?a='.$album.'&i='.$filename.'&s=thumb">';

    echo '

    ';

    }

    }

    ?>

    ``````
  • acrylian Administrator, Developer
    You need to define the webpath in this part `define('WEBPATH', '');` For example something like `http://www.yoursite.com/zenphoto`
  • The function `printLatestImages` is part of zenphoto. You should delete the declaration of it from your page.
  • there should be a slash in the line
    `require_once(WEBPATH . "" . ZENFOLDER . "/template-functions.php");`

    `require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");`

    The WEBPATH define should match the folder where zenphoto is installed. I.e. if your zenphoto php files are in `photos/zp-core/` then the define would be `define('WEBPATH', 'photos');`

    Anyway, the page you show seems only to be defining the function `printlatestimages()` which you don't need to (and are not allowed to) do.

    Please look at the WIKI description for use of zenphoto as a plugin.http://www.zenphoto.org/trac/wiki/ZenphotoHacks#zenphotoasaplug-in

    Follow this example to edit your php page that you want to display zenphoto images. Place the call on `printlatestimages()` where you want the images to appear on your web page.

    For a full example of an index.php page that displays a random image:
    `<?php <br />
    define('ZENFOLDER', 'zp-core');

    define('WEBPATH', 'zenphoto');

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    header ('Content-Type: text/html; charset=' . getOption('charset'));

    ?>





    Test Index





    <?php <br />
    $randomImage = getRandomImages();

    $randomImageURL = getURL($randomImage);

    echo "image
    $randomImage->getSizedImage(getOption('image_size')) .

    "' alt="random image"n" . $randomImage->getTitle() .

    '" />
    ';

    ?>



    `

    Your page would, of course display more items and use the `printlatestimages()` function in place of the random image code.
  • OK, just to be more to the point, I have changed my test home page to put out the latest images as you want to do. Here is the index.php file. (note that there is no adornment to the page, it just shows the images.)
    `<?php <br />
    define('ZENFOLDER', 'zp-core');

    define('WEBPATH', 'zenphoto');

    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    header ('Content-Type: text/html; charset=' . getOption('charset'));

    ?>





    Test Index





    <?php <br />
    printLatestImages();

    ?>



    `
  • Thank you everyone, especially sbillard, for your help :)
Sign In or Register to comment.