1 (edited by 2010-08-12 05:15:19)

Topic: [HACK] Gravatar

Name: Gravatar
Author: V4NY
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Hi all.
I made this hack to display Gravatar in comments (see http://gravatar.com). I can't post in the hack forum so i hope you can move this topic there.
Instructions:

Open shows.inc.php in the inc directory, go to line 393 (circa) and find this line:

$output = str_replace("{mail}", "$comment_arr[2]",$output);

Add before this:

$size = 80; //size of gravatar
$default = "http://layoutstudios.com/images/noava.gif"; //default gravatar
$grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($comment_arr[2])."&default=".urlencode($default)."&size=".$size; //generating url
$output = str_replace("{gravatar}", "<img src=\"".$grav_url."\" align=\"left\" alt=\"\" />",$output); //template tag


change the variable values for $size and $default.
Save and exit.
You can now use the tag {gravatar} in templates http://cutephp.com/forum/style_emoticons/default/smile.gif

Re: [HACK] Gravatar

I can honestly say I have not tried this yet but it sounds like it works and the coding involved looks to be whats needed smile

Great work V4NY smile

3 (edited by 2011-03-11 16:18:34)

Re: [HACK] Gravatar

Title:Gravatar for Cutenews
Author: Sierron
Cutenews Compatibility: 1.3.6
Description:This hack adds the ability to show a gravatar for news comments. Only on commenting!
Discussion Topic: here
Instructions:

open [cutenewsfolder]/inc/show.inc.php

Find

<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>            $output = str_replace('{mail}', $comment_arr[2], $output);
            $output = str_replace('{date}', utf8_dates(date($config_timestamp_comment, $comment_arr[0])), $output);
            $output = str_replace('{comment-id}', $comment_arr[0], $output);
            $output = str_replace('{comment}', "<a name=\"".$comment_arr[0]."\"></a>$comment_arr[4]", $output);
            $output = str_replace('{comment-iteration}', $iteration ,$output);</div>
Add below

<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>            // gravatar mod begin
            // with replacer if no image was found
            if((!preg_match("^://^",$comment_arr[3]))&&($comment_arr[3] != "none"))
            {
                $gravsize = "50"; // size of the gravatar. 512 is maximum
                $gravtype = "wavatar"; // following are available: identicon, monsterid and wavatar
                $gravatar = strtolower($comment_arr[2]);
                $gravatar = md5($gravatar);
                $output = str_replace("{gravatar}", "<img src=\"http://www.gravatar.com/avatar/$gravatar?s=$gravsize&d=$gravtype\" style=\"height: ".$gravsize."px; width: ".$gravsize."px;\" alt=\"$gravatar\">",$output);
            }
            else
            {
                $output = str_replace("{gravatar}", "",$output);
            }
            // gravatar mod end</div>


How to use in templates:
{gravatar} Is the code for the gravatar.


Changelog:
v. 1.1: also checking if the email address is "none"