Recent Topics

Gravatar Hack for b2evo 2.4.x

Started by on Jan 03, 2009 – Contents updated: Jan 03, 2009

Jan 03, 2009 12:20    

Hi @lltogether,

you wanna use gravatars on your site but cannot use the [url=http://forums.b2evolution.net/viewtopic.php?t=15641]avatar_plugin[/url]?
[url=http://forums.b2evolution.net/viewtopic.php?t=17547]I´ve had the same problem[/url] but now there´s a solution - simply edit your stylesheet und _item_comment.inc.php!

[url=http://forums.b2evolution.net/profile.php?mode=viewprofile&u=1511]¥åßßå[/url] helped me out and here is how:
http://j-sys.de/index.php/2009/01/03/b2evo-und-gravatars
(German!)

Shortly in english:
Append following code to your stylesheet


/* Gravatar style */
img.show_gravatar {
    margin:7px;
    padding:1px;
    border:1px solid #CCCCCC;
    background-color:white;
}

and edit _item_comment.inc.php like that (starting at line 80, after <?php $Comment->rating();)


<?php $Comment->rating();
        if( !empty( $Comment->author_User ) )
        {
            $email = $Comment->author_User->get( 'email' );
        }
        else
        {
            $email = $Comment->author_email;
        }
    $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($email); ?>
    <div style="float:left"><img class="show_gravatar" src=<?echo $grav_url;?> width="60" height="60" /></div>    
    <div class="bCommentText">
        <?php $Comment->content() ?>
    </div> 

Be sure to copy _item_comment.inc.php to your skins subdir _before_ editing the file!

Have fun!
And once again many thx to ¥åßßå!!!

Cheers,
Joshua

Oct 11, 2009 10:18

Hi,

Your tip really useful. I made the necessary corrections in my php and css files and now my avatars were working fine. Thanks a bunch for such a nice and useful information.

I slightly increased the width and height of the image by 10 pixels and added a margin of 3px to the image so that it looks pretty cool in all the posts.

Thanks again for the trick!
-Arunprasad.R :D

Dec 07, 2009 00:03

I use this hack on b2evolution 2.4.7
It shows gravatar for non-logged user but not for logged-in users.

Do you have any idea ?

Dec 08, 2009 18:05

For what it's worth: gravatar support is built in in b2evo v4/CVS. That was contributed by sam2kb if I'm not mistaken.

Dec 11, 2009 21:11

I adapted the hack for b2evo 2.4.7 skins glossyblue

Edit the file

Add around line 165


                <!-- ========== START of a COMMENT/TB/PB ========== -->

                <li id="comment-<?php $Comment->ID(); ?>" class="<?php echo $oddcomment; ?>"><?php $Comment->anchor() ?>


                        <? // slamp_091206_begin_gravatar
                                if( $Comment->get_author_User() )
                                { // This comment is from a registered user:
                                        if( empty($Comment->author_User->email) )
                                        { // We have no email for this Author :(
                                                $grav_email = $Comment->author_email;
                                                $grav_title = "Your avatar on www.gravatar.com";
                                        }   
                                        else
                                        {   
                                                $grav_email = $Comment->author_User->get('email');
                                                $grav_title = "Avatar of " . $Comment->author_User->get('preferredname');
                                        }   
                                }   
                                else
                                { // This comment is from a visitor:
                                        $grav_email = $Comment->author_email;
                                        $grav_title = "Your avatar on www.gravatar.com";
                                }   
                                $grav_url = "http://www.gravatar.com/avatar.php?rating=G&size=40&gravatar_id=".md5($grav_email)."&d=identicon"; 
                        ?>  
                        <div style="float:right"><img class="show_gravatar" src=<?php echo $grav_url; ?> width="40" height="40" alt="gravatar" title="<?php echo $grav_title; ?>" /></div>
                        <!--  slamp_091206_end_gravatar -->


                        <?php
                                switch( $Comment->get( 'type' ) ) 
                                {   


Form is loading...

Run your own website! – This forum is powered by b2evolution CMS, a complete engine for your website.