I would also like to show the lates comments in my index.php. But the spinnet is not working because it contains "zp_conf"
Can anyone take a look at it and fix it. Thanks in advance!
/* Show Latest Comments */
/* http://anton.gektoras.lt/2007/05/15/zenphoto-addons/ */
function my_truncate_string($string, $length) {
if (strlen($string)> $length) {
$short = substr($string, 0, $length);
return $short. '...';
} else {
return $string;
}
}
function printLatestComments($number) {
echo '<div id="showlatestcomments">';
echo '
[list]';
$comments = query_full_array("SELECT c.id, i.title, i.filename, a.folder, a.title AS albumtitle, c.name, c.website,"
. " c.date, c.comment FROM ".prefix('comments')." AS c, ".prefix('images')." AS i, ".prefix('albums')." AS a "
. " WHERE c.imageid = i.id AND i.albumid = a.id ORDER BY c.id DESC LIMIT $number");
foreach ($comments as $comment) {
$author = $comment['name'];
$album = $comment['folder'];
$image = $comment['filename'];
$albumtitle = $comment['albumtitle'];
if ($comment['title'] == "") {
$title = $image;
} else {
$title = $comment['title'];
}
$website = $comment['website'];
$comment = my_truncate_string($comment['comment'], 40);
$link = $author.' commented on '.$albumtitle.' / '.$title ;
$short_link = my_truncate_string($link, 40);
echo '
[*]<div class="commentmeta"><a href="';
if (zp_conf('mod_rewrite') == false) {
echo WEBPATH.'/index.php?album='.urlencode($album).'&image='.urlencode($image).'/"';
} else {
echo WEBPATH.'/'.$album.'/'.$image.'" ';
}
echo 'title="'.$link.'">';
echo $short_link.':</div><div class="commentbody">'.$comment.'</div>
';
}
echo '[/list]
';
echo '</div>';
}