hi all,
1st off many thanks to all for their hard work in making an easy-to-use gallery - i love it's simplicity.
right, onto my little request
i noticed that the 'thinkdreams' theme has a random image display, so i thought that it would be nice to have (where the description area is) a similar module - but this one to display the latest image. anyway. after a few "hacking" attempts (i'm not good with php) i've just ended up with an error. i'll details what i did to get to the stage i'm currently on...
in the 'thinkdreams-function.php' file i copied them just underneath and did some renaming. here's what i've ended up with:
[CODE]// Get Random Image
function getRandomImage()
{
$resultRandom = query_single_row('SELECT '.prefix("images").'.filename, '.prefix("images").'.title, '.prefix("albums").'.folder FROM '.prefix("images").' INNER JOIN '.prefix("albums").' ON '.prefix("images").'.albumid = '.prefix("albums").'.id ORDER BY RAND() LIMIT 1');
$imageRandom = new Image(new Album(new Gallery(), $resultRandom['folder']), $resultRandom['filename']);
return $imageRandom;
}
// Get Random Image Link
function getRandomURL($imageRandom)
{
if (zp_conf('mod_rewrite'))
{
return WEBPATH . "/" . urlencode($imageRandom->getAlbumName()) . "/" . urlencode($imageRandom->name);
}
else
{
return WEBPATH . "/index.php?album=" . urlencode($imageRandom->getAlbumName()) . "&image=" . urlencode($imageRandom->name);
}
}
// Get Latest Image
function getLatestImage()
{
$resultLatest = query_single_row('SELECT '.prefix("images").'.filename, '.prefix("images").'.title, '.prefix("albums").'.folder FROM '.prefix("images").' INNER JOIN '.prefix("albums").' ON '.prefix("images").'.albumid = '.prefix("albums").'.id ORDER BY '.prefix("images").'.id DESC LIMIT 1');
$imageLatest = new Image(new Album(new Gallery(), $resultLatest['folder']), $resultLatest['filename']);
return $imageLatest;
}
// Get Latest Image Link
function getLatestURL($imageLatest)
{
if (zp_conf('mod_rewrite'))
{
return WEBPATH . "/" . urlencode($imageLatest->getAlbumName()) . "/" . urlencode($imageLatest->name);
}
else
{
return WEBPATH . "/index.php?album=" . urlencode($imageLatest->getAlbumName()) . "&image=" . urlencode($imageLatest->name);
}
}[/CODE]
on the 'index.php' page i've added:
[CODE]<div class="module">
<h2>Latest Image</h2>
<?php
$latestImage = getLatestImage();
$latestImageURL = getLatestURL($randomImage);
echo '
getTitle().'"><img src="'.$latestImage->getCustomImage(null, 230, null, 210, 90, null, null).'" alt="'.$latestImage->getTitle().'" id="latest" />';
?>
</div>[/CODE]
the error i'm getting is "Fatal error: Call to a member function getAlbumName() on a non-object".
could anyone share any light on where i've gone wrong?
thanks in advance.
Comments
[CODE]<div class="module">
<h2>Latest Image</h2>
<?php
$latestImage = getLatestImage();
$latestImageURL = getLatestURL($latestImage);
echo 'getTitle().'"><img src="'.$latestImage->getCustomImage(null, 230, null, 210, 90, null, null).'" alt="'.$latestImage->getTitle().'" id="latest" />';
?>
</div>[/CODE]