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
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 '
src="'.WEBPATH.'/cache/'.$album.'/'.$filename.$size.'.jpg">'; */
echo '
src="'.WEBPATH.'/zen/i.php?a='.$album.'&i='.$filename.'&s=thumb">';
echo '
';
}
}
?>
``````
`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 "
$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.
`<?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();
?>
`