Pour remplacer le message vide de
ce post
Si quelqu’un peut le traduire je suis OK
ATTENTION pour utiliser cette fonctionnalité vous devez Modifier (hacker) le snippet eForm
1)
Modification du snippet eForm
Ajouter le code suivant de
Pixelchutes dans le snippet eForm ligne 93 :
if( $params[to]{0} == '(' ) $params[to] = str_replace( array('((','))'), array('[+','+]'), $params[to] ); // PHx workaround
if( $params[from]{0} == '(' ) $params[from] = str_replace( array('((','))'), array('[+','+]'), $params[from] ); // PHx workaround
if( $params[fromname]{0} == '(' ) $params[fromname] = str_replace( array('((','))'), array('[+','+]'), $params[fromname] ); // PHx workaround
if( $params[replyto]{0} == '(' ) $params[replyto] = str_replace( array('((','))'), array('[+','+]'), $params[replyto] ); // PHx workaround
$params[subject] = str_replace( array('((','))'), array('[+','+]'), $params[subject] ); // PHx workaround
Ce code permet d’utiliser n’importe lequel des champs du formulaire eForm comme valeur des paramètres &to, &from, &fromname, &replyto et &subject en utilisant la syntaxe ((nomDeMonChamp)) ex : &to=`((friendemail))`
2)
Formulaire d’envoi du mail
Chunk : sendToAFriendForm
<p><span style="color:#900;">[+validationmessage+]</span></p>
<form id="formSTF" name="formSTF" method="post" action="[~[*id*]~]">
<table width="450" border="0">
<tr>
<td width="220"> Your friend name :<br>
<input id="friendname" name="friendname" type="text" eform="Nom ami:string:1:Le nom est obligatoire" /> </td>
<td width="220"> Your friend e-mail <br>
<input id="friendemail" name="friendemail" type="text" eform="E-mail ami:email:1:" /> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td> Your name :<br>
<input id="yourname" name="yourname" type="text" eform="Votre nom:string:1:Le nom est obligatoire" /> </td>
<td>
Your e-mail :<br>
<input id="youremail" name="youremail" type="text" eform="Votre email:email:1:" /> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2">
Message :<br>
<textarea id="message" name="message" rows="7" eform="Message:string:1:Le message est obligatoire"></textarea> </td>
</tr>
<tr>
<td>
Merci d'entrer le code anti spam suivant : <br>
<img src="[+verimageurl+]" alt="verification code" border="1"/> </td>
<td>
Code : <input type="text" name="vericode" size="20" /> </td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="Submit" value="Envoyer">
</td>
</tr>
</table>
</form>
3)
Template du mail envoyé à l’ami
Chunk : formSTFemail
<table width="515" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="15"> </td>
<td height="50" align="center" valign="top"><br>
<table width="495" height="28" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left"><span class="Style4">[+emailTitle+]</span></td>
</tr>
</table>
<br>
<table width="500" border="0" cellpadding="20" cellspacing="0">
<tr>
<td align="left" valign="top" bgcolor="#F9FAF4" class="Style1">
Hello <strong>[+friendname+]</strong>,<br>
<strong>[+yourname+]</strong> send you this message :<br>
<br>
[+message+]
<br/>
See this page : [+link+]
</td>
</tr>
</table> </td>
</tr>
</table>
4)
Snippet permettant de récupérer l’url de la page visitée (page précédante)
Snippet : eFormSTF
<?php
function eFormSTFlink( &$fields ){
global $modx;
$fields['link'] = '<a href="'.$_SERVER['HTTP_REFERER'].'" >'.$_SERVER['HTTP_REFERER'].'</a>' ; // 'http://www.toto.com';
return true;
}
?>
5) Page contenant le formulaire d’envoi du mail
[[eFormSTF]]
[!eForm? &formid=`formSTF` &tpl=`sendToAFriendForm` &report=`formSTFemail` &thankyou=`formSTFtyou` &subject=`Envoyer a un ami` &vericode=`1` &debug=`2` &to=`((friendemail))` &from=`((youremail))` &fromname=`((yourname))` &eformOnBeforeMailSent=`eFormSTFlink`!]
Et voilou !!