Latest comments on index

Hi,

I'm new here and a bit confused right now. I want to add the 3 latest comments to my gallery-indexpage. I found http://www.zenphoto.org/trac/wiki/ZenphotoHacks#RecentCommentsCustomFunction but my php knowledge is limited and the FAQ didn't help much. In other words I have no clue how to add this function to my gallery. So can anyone point me in the right direction?

Thanks!

Comments

  • If you have a custom-functions file you can drop that code in there, otherwise you can put it in template-functions.php. After youve done this you can put <?php show_latest_comments(3); ?> in your theme page to show the 3 latest comments.

    It is recommended that you put this code in a file called custom-functions.php and include it at the top of your theme files using this code: <?php require_once ('custom-functions.php'); ?>
    What this will do is allow you to upgrade zenphoto without having to modify the zenphoto code every time you upgrade.
  • Ah thank you!
  • 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 '
      ';
      $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 '
    ';
    echo '</div>';
    }
  • The `zp_conf` array has been eliminated now that options are stored in the database. Use instead `getOption('mod_rewrite')`

    On the other hand, there is a function for this: `printLatestComments($number)` which you might rather use. It is part of template-functions.php.

    We are hard at work and should shortly have an updated function guide posted on the zenphoto site.
  • Nice sbillard, that is exactly what I meant when I said I needed some parameters. A list of funciton would be superb!!!!!!
Sign In or Register to comment.