Gravatar for CakePHP

I've been playing around with CakePHP for a week or so and I think it has a lot of potential. The framework feels robust, complete and very handy once you get to know it. "As every thing else" I hear you saying, but the problem I'm having with CakePHP is the documentation.

Most of the times it's incomplete or just assumes that you know way too much about the framework. Getting to work a simple authentication system using their built-in component has been quite a bit of a pain. And I'm not alone, the docs, the mailing list and many other blogs complain about the same. I'm thinking about writing yet another tuto myself, it's really frustrating when you just want to get things done and you can't...

I hope I've learnt from others so I'd make kick ass docs for HippoHX both for advanced developers AND newbies. Even though documenting sucks you/we must create good documentation.

Anyway. I've created a very simple Helper to handle Gravatars. Certainly not rocket science, but here it is:

[code lang="php"]
/*
* Gravatar Helper.
* First import it. Either globally in your app_controller.php (app/app_controller.php) or in a specific controller:
* var $helpers = array('Gravatar');
*
* Then just call it from your view like this:
* $gravatar->get(wadus@wadus.com);
*/

class GravatarHelper extends Helper {

var $helpers = array('Html');

function get($email,$size = 40){
return $this->output($this->Html->image("http://www.gravatar.com/avatar.php?gravatar_id=".md5($email)."&size=".$size));
}

}
[/code]

So simple it doesn't need documentation :P

Back to index