by
KK » Mon Jul 09, 2012 8:23 am
Hi,
We'll have to use shortcodes (
http://www.couchcms.com/docs/miscellane ... codes.html) to achieve that.
The kfunctions.php given the documentation already has a shortcode for obfuscating emails. We'll make a little modification to it to make it work the way you want.
Please find the following lines and replace the highlighted line..
// 6.
// Obfuscate email
// Usage: [mailto]email@mydomain.com[/mailto]
$FUNCS->register_shortcode( 'mailto', 'mailto_handler' );
function mailto_handler( $params, $content=null ){
global $FUNCS;
// Create Couch script.. we'll use the 'cloak_email' tag to encrypt email
$html = "<cms:cloak_email email='{$content}' />";
// Pass on the code to Couch for execution using the 'embed' function
return $FUNCS->embed( $html, $is_code=1 );
}
.. as follows
// 6.
// Obfuscate email
// Usage: [mailto]email@mydomain.com[/mailto]
$FUNCS->register_shortcode( 'mailto', 'mailto_handler' );
function mailto_handler( $params, $content=null ){
global $FUNCS;
// Create Couch script.. we'll use the 'cloak_email' tag to encrypt email
$html = "<cms:cloak_email \"<cms:get_custom_field 'email_address' masterpage='globals.php' />\" />";
// Pass on the code to Couch for execution using the 'embed' function
return $FUNCS->embed( $html, $is_code=1 );
}
Now (as explained in the docs), if your editable region was, for example, named 'my_content' and this is how you were outputting its content in the template
- Code: Select all
<cms:show my_content />
simply enclose it with <cms:do_shortcodes> tags like this
- Code: Select all
<cms:do_shortcodes><cms:show my_content /></cms:do_shortcodes>
This will now make Couch execute any shortcodes the user inputs into the editable region.
You can now output the obfuscated email simply by inputting the following shortcode within the editable region
- Code: Select all
[mailto]
Hope this helps.