Firefox PHP

Module: Gravatar

Posted by Phil Connolly 
All files from this thread

File Name File Size   Posted by Date 15.6 KB open | download Phil Connolly 09/09/2010 Read message
gravatar_img_read.tpl 122 bytes open | download Phil Connolly 04/11/2011 Read message
Module: Gravatar
December 03, 2009 01:52AM
This module makes it possible to add Gravatars ( to your
forums and user profiles. Features:

o Installs without template modification, however provides template variables for Admins
who wish to have more control over gravatar integration (See the README)
o Module will autoinsert gravatars next to user's name/username.
o Users can control the display and maximum rating of their own gravatars.
o Admin interface to enable autoinsert for various sections of Phorum.
o Admin interface to set gravatar size, and maximum allowable rating (default is G-rated).
o Admin interface to set default gravatar.
o User rating selection cannot exceed Admin setting.
o Gravatar HTML is customizable (after installing see ./mods/gravatar/templates/emerald/ folder)
o All strings defined in module language file

Copy the contents of the attached Zip file into your mods directory. In the Phorum Admin section, go to Modules and turn on the Gravatar module. By default it will begin retrieving gravatars, using a G rating and default size of 80 pixels. Your users can hide their gravatar in the privacy settings, and set a lower rating for their own gravatars than you set in the module settings.

What else... you can either let the module insert the gravatar automatically in all the places it wants to, or you can turn that feature off and do your own template customizations. See the README for more details.

Feedback and critique welcomed... this is only my second module so I am sure I have a few things still to learn about this stuff. Not to mention I am a C# guy, not really php.... what the heck... welcome me to the dark side :-)


2010-09-09 v1.0.5

    - Fixed formatting problem with flat read views (thanks to Lord_ZealoN for reporting the issue)
    - Added a "Header topic" option for gravatar autoinsert, to support gravatars display in the header template
    - Updated README to describe header.tpl template customization

2010-03-15 v1.0.4

    - Added HTTP 404 as an option to Gravatar defaults
    - Updated README to provide instructions for integrating Gravatar and User Avatar modules
    - Updated README to included further instructions for template customization

2010-01-27 v1.0.3

    - Fixed formatting problem with gravatar in Preview view of private message when no recipient is added.

2009-12-04 v1.0.2

    - Added gravatars to Preview view of new private message.

2009-12-03 v1.0.1

    - Renamed the hook functions to conform to the naming convention recommended by Phorum.
    - Added gravatars to Private Messaging and to the Buddy List.
    - Refactored some of the code to be more efficient.

2009-12-02 v1.0.0

    - Initial release

To Do: figure out a way to integrate this with one or both of the Avatar mods already available. Right now this would probably not play too nicely with them, but there are probably ways to have them live together and give each user the choice.

Edited 8 time(s). Last edit at 09/09/2010 10:01PM by Phil Connolly.
open | download - (15.6 KB)
Re: Module: Gravatar
January 28, 2010 08:37PM
Update: new version released today addressing a few bug fixes.
Re: Module: Gravatar
January 29, 2010 03:07PM
I've only recently figured out what gravatars are and might play around with this in the next week or so.

I currently use the User Avatar mod, so either there would have to be a way for the user to choose, or a template statement I could implemement.

{Edited to remove suggested code in favor of much cooler suggested code below - Bob}

Or something like that. I havent downloaded your mod yet to play around.

Robert Angle
Phorum lover, nothing more.

Edited 1 time(s). Last edit at 03/04/2010 09:11PM by Robert Angle.
Re: Module: Gravatar
January 29, 2010 06:38PM
Robert Angle
I currently use the User Avatar mod, so either there would have to be a way for the user to choose, or a template statement I could implemement.

I have been meaning to take a close look at User Avatar to see what might be the best strategy for both to coexist side by side. But I haven't gotten around to it yet... so all ideas are welcomed.


Edited 1 time(s). Last edit at 01/29/2010 07:40PM by Phil Connolly.
Re: Module: Gravatar
March 04, 2010 01:00PM
Any more thoughts about making this module work with other avatar support?
e.g. another per-user default option to use avatar configured elsewhere (or opt-out)
maybe with a system wide setting to control it
Re: Module: Gravatar
March 04, 2010 08:40PM
I haven't gotten very far with figuring out the right strategy. I wrote the gravatar module in such a way that it is oblivious to user_avatar. In retrospect, perhaps I should have mod-ed user_avatar and extended it to support gravatars. But being what it is in its current form, I think I will just look at a way for gravatar module to put its user settings on the Avatar control center panel, and let the user choose which one to enable for himself. I don't yet know if this is a viable solution, I need to look at user_avatar code more closely to see what is possible. Maybe Maurice or Thomas are listening in on this conversation and will have some advice.

In some tests I have done I think they can run side-by-side on the same phorum installation, but it has to be an either/or from the user's perspective, because each module uses a completely different avatar insertion mechanism, and they will not be compatible. A user selects a gravatar, the module has to turn off the avatar for that user. The user selects an avatar, the module turns off the gravatar for that user. Looking at user_avatar's code I think it is just setting a single flag to control whether a user's avatar displays, I can probably change that flag setting within gravatar module. I will try and have an answer this week, as to what the next direction for this module will be.

Re: Module: Gravatar
March 04, 2010 09:08PM
I say make an option so that you have to do a template customization. This way we could code the template like this...

{IF USER->gravatar}
<!--code to insert gravatar image-->

And then, if an admin like myself wanted to run both Gravatar and Avatar modules, then code like the following could be used...

Language: PHP
{IF USER->avatar} <!--code to insert avatar image--> {ELSE} {IF USER->gravatar} <!--code to insert gravatar image--> {/IF} {/IF}

This would make Gravatar the default, which would be overwritten / over-ruled by the avatar module if a user decided to upload one.

Robert Angle
Phorum lover, nothing more.

Edited 1 time(s). Last edit at 03/04/2010 09:09PM by Robert Angle.
Re: Module: Gravatar
March 04, 2010 10:34PM
Your idea should already be supported by gravatar module. By default, the module automatically inserts the gravatar into phorum output, without any template changes. But if you want to modify your templates, you can disable "gravatar autoinsert" in the module's Admin settings, and then use the template variables. The module's Readme file has some example snippets.

To specifically do what you are suggestion, i.e., code for both modules and make the gravatars to be the fallback default, you could do something like this (example shown places either the avatar or gravatar on the Profile, aligned to the right):

Language: HTML
{IF PROFILE->user_avatar} <img src="{PROFILE->user_avatar}" alt="avatar" {IF PROFILE->user_avatar_w} style="width:{PROFILE->user_avatar_w}px; height:{PROFILE->user_avatar_h}px" {/IF} align="right" /> {ELSE} {IF PROFILE->MOD_GRAVATAR} <img src="{PROFILE->MOD_GRAVATAR->url}" align="right"> {/IF} {/IF}

This snippet should display the user's avatar if he has one available, and if not show the user's gravatar. If there is no gravatar for the user, then it will display the default image or a blank gif. Those last options are controlled in the module's Admin settings.
Re: Module: Gravatar
March 04, 2010 10:42PM
There we go, solution works for me :-)

I hadn't downloaded this yet, but saw that line that said no template changes needed and thought that it was all done without changes.

Robert Angle
Phorum lover, nothing more.
Re: Module: Gravatar
March 04, 2010 10:48PM
I see how that line is misleading... I re-phrased it to indicate both modes are available. Thanks for pointing that out!

Sorry, only registered users may post in this forum.

Click here to login