Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
3 posts Page 1 of 1
I created a website for someone with very low confidence on a computer. Explaining about mailto links and email obfuscation was not an option. She needed to be able to just type email addresses anywhere without having to think about it.

So I made the email_guardian tag to scan for email addresses and automatically obfuscate them using Couch's cloak_email tag.

I know a lot of people don't think twice about posting an email address on the web, so this tag could be a useful tool for designers who want to make it easy for people but still keep them protected.

Simply wrap any portion of code in the <cms:email_guardian> tag to scan for and encrypt all email addresses.
Code: Select all
    <cms:show my_blog_post />

To enable the tag, add the following code to your couch/addons/kfunctions.php file.
Code: Select all
class CustomTags {
    static function email_guardian( $params, $node ){
        global $FUNCS;
        foreach( $node->children as $child ){
            $html .= $child->get_HTML();
        preg_match_all('/\b[^\s]+@[^\s]+/', strip_tags(htmlspecialchars_decode($html, ENT_QUOTES)), $emails);
        foreach($emails[0] as $email){
            $email = trim(strtolower($email), ".,;:?!\"\'‘’‚“”„‹›-+&#*%$@~`^()|<>[]{}/\\");
            $code = $FUNCS->embed( "<cms:cloak_email email='{$email}' />", $is_code=1 );
            $pos = strpos($html, $email);
            if ($pos !== false) {
                $html = substr_replace($html, $code, $pos, strlen($email));
        return $html;
$FUNCS->register_tag( 'email_guardian', array('CustomTags', 'email_guardian') );
This is great Tim - my congratulations :D :D :D
+1 for this from me too?

I guess most "normal users" (picture a busy small business owner) will have difficulties keeping the shorthand mailto tag in their mind...
3 posts Page 1 of 1

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 2 guests