Gravatar in comments

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
Paal
Posts: 204
Joined: Wed 6. Oct 2004, 19:54
Location: Budapest, Hungary
Contact:

Gravatar in comments

Post by Paal »

Hello,

I tried to use the gravatar image in comments. Gravatar use MD5 encoded e-mail address.
What is a gravatar?

A gravatar, or globally recognized avatar, is quite simply an 80×80 pixel avatar image that follows you from weblog to weblog appearing beside your name when you comment on gravatar enabled sites. Avatars help identify your posts on web forums, so why not on weblogs?
More information in gravatar homepage.

CREATE reptag_MD5.php in phpwcms_template/inc_script/frontend_render/ folder.

Code: Select all

<?php
function showMD5value($value = '')
{
  return md5($value);
}


// -------------------------------------------------------------
  $content["all"] = preg_replace('/\{MD5:(.*?)\}/ie', 'showMD5value("$1");', $content["all"]);
// -------------------------------------------------------------
?>

COPY default.html to comments.html in phpwcms_template/inc_cntpart/guestbook/ folder.

EDIT comments.html in phpwcms_template/inc_cntpart/guestbook/ folder:

FIND the <!--GUESTBOOK_ENTRY_START//--> section and ADD this img tag:

Code: Select all

<img src="http://www.gravatar.com/avatar.php?gravatar_id={MD5:{EMAIL}}&size=40" alt="{NAME}">
EDIT the comment article in phpwcms backand, and select comments.html for template.

Check the results ;) (when the poster users have gravatar)


The result (it's my gravatar):

Code: Select all

<img src="http://www.gravatar.com/avatar.php?gravatar_id=59cca5a3307b5701408961bcec2ba2c5&size=40" alt="Palócz Pál">
Thx Erich_k4s and jscholtysik for reptag_MD5.php hack!

Paul
Post Reply