Hello.
I was trying to build a shortcode that would replace everything in between the brackets with some specific words.
Here's what I did :
This shortcode would only be displayed and used on the "contrat-conf.php" page, which has the following code:
See where the [replace_variables] shortcode is?
I need to make sure it scans the "gabarit_content" before it sends the email, and replaces every occurence of [name] by the name matching that page ID in the "contrats.php" page. Same for [phone].
The "gabarit_content" region currently echoes the following text:
Obviously, I need to replace [name] with the name of the person entered in the "contrats.php" page, with a matching ID, and so on.
Any idea how to make this work?
I would create different shortcodes for different pages if needed.
Thanks a lot
I was trying to build a shortcode that would replace everything in between the brackets with some specific words.
Here's what I did :
- Code: Select all
$FUNCS->register_tag( 'replace_variables', replace_variables_handler );
function replace_variables_handler( $params, $node ){
global $FUNCS;
// call the children
foreach( $node->children as $child ){
$html .= $child->get_HTML();
}
$html = str_replace("[name]", "<cms:pages masterpage="contrats.php" custom_field='my_uid=notification_contrat_relie' ><cms:show workers_name /></cms:pages>", $html );
$html = str_replace("[phone]", "<cms:pages masterpage="contrats.php" custom_field='my_uid=notification_contrat_relie' ><cms:show workers_phone /></cms:pages>", $html );
return $html;
}
This shortcode would only be displayed and used on the "contrat-conf.php" page, which has the following code:
- Code: Select all
<cms:pages masterpage="notifications/contrat-conf.php" custom_field="date_envoi_contrat_conf=<cms:date format='Y-m-d H:i:00' />">
<cms:send_mail from='admin@mysite.com' to="<cms:show_repeatable 'destinataires'><cms:show destinataire_simple/></cms:show_repeatable>" subject='Subject' debug="1">
<cms:related_pages 'notification_contenu' >[replace_variables]<cms:show gabarit_content/>[/replace_variables]</cms:related_pages>
</cms:send_mail>
</cms:pages>
See where the [replace_variables] shortcode is?
I need to make sure it scans the "gabarit_content" before it sends the email, and replaces every occurence of [name] by the name matching that page ID in the "contrats.php" page. Same for [phone].
The "gabarit_content" region currently echoes the following text:
- Code: Select all
Hello [name]!
Here's your new phone number : [phone]
Enjoy!
Obviously, I need to replace [name] with the name of the person entered in the "contrats.php" page, with a matching ID, and so on.
Any idea how to make this work?
I would create different shortcodes for different pages if needed.
Thanks a lot