Dotclear

Ticket #2143 (closed defect: fixed)

Opened 10 years ago

Last modified 10 years ago

Balise tpl:EntryAuthorEmailMD5 ?

Reported by: MathieuM Owned by: team
Priority: normal Milestone: 2.9
Component: module:core Version: 2.8.1
Severity: normal Keywords:
Cc:

Description

Bonjour,

Comme il existe une balise  {{tpl:CommentAuthorMailMD5}}, permettant, entre autres choses, de profiter du service Gravatar, il serait super cool d'avoir son équivalent {{tpl:EntryAuthorEmailMD5}} (la balise sans "MD5" existe déjà).

Ça serait rudement chouette, en tout cas j'en vois une bien belle utilisation pour ma pomme :)

Change History

comment:1 Changed 10 years ago by franck

En attendant tu peux toujours mettre le code idoine dans un _public.php de ton thème, ça devrait rouler pour ta pomme ;-)

comment:2 Changed 10 years ago by MathieuM

Je dois faire ça comme un pied, mais en essayant le code suivant :

# We want to create a {{tpl:EntryAuthorEmailMD5}} tag
$core->tpl->addValue('EntryAuthorEmailMD5',array('tplMyMoreTpl','EntryAuthorEmailMD5'));
 
class tplMyMoreTpl
{
	
	public static function EntryAuthorEmailMD5($attr)
	{
		return '<?php echo md5($_ctx->posts->getAuthorEmail); ?>';
	}
}

Puis dans mon gabarit :

<img src="http://www.gravatar/avatar/{{tpl:EntryAuthorEmailMD5}}?s=24" alt="" />

J'obtiens bien le code suivant :

<img src="http://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?s=24" alt="" />

Mais cette URL encodée en MD5 ne me renvoie pas le gravatar associé à l'adresse email de l'auteur.

Ai-je manqué quelque chose ? (fort possible)

Est-ce lié au fait que {{tpl:EntryAuthorEmail}} ne retourne pas une belle address@… mais plutôt address%40email%2eltd ?

Merci ;)

comment:3 Changed 10 years ago by franck

C'est surtout que getAuthorEmail est une fonction, donc faut a minima un () après, et même un (false) dans ton cas pour éviter l'encodage, donc :

return '<?php echo md5($_ctx->posts->getAuthorEmail(false)); ?>';

plutôt.

comment:4 Changed 10 years ago by MathieuM

Parfaitement parfait ! \o/

comment:5 Changed 10 years ago by franck

  • Milestone changed from A definir to 2.9

comment:6 Changed 10 years ago by franck <carnet.franck.paul@…>

  • Status changed from new to closed
  • Resolution set to fixed

(In [c889dac8b2b9]) Add tpl:EntryAuthorEmailMD5 tag, closes #2143

Note: See TracTickets for help on using tickets.

Sites map