2

I'm in Drupal 7 and using Contemplate and Invisimail, but I can't figure out how to get my emails to be obfuscated.

I think it is because the display of the node is using the contemplate template, which simply says:

<?php print $node->field_email['und'][0]['email'] ?><br/>

I figure I have to wrap that in a call to invisimail_encode_email, as such:

<?php print invisimail_encode_email($node->field_email['und'][0]['email'], 'html_entities') ?><br/>

but that did not work (error message about undefined array index). So, maybe I'm calling that function with the wrong parameters? or maybe I'm calling the wrong function.

Basically, how do I call invisimal from within php?

2
  • Ok, I used invisimail_encode_html($node...) instead and that encoded the email, but I'm still not sure if _encode_html actually does the full obfuscation thing. Commented May 17, 2011 at 13:21
  • you could check with a drupal_set_message(invisimail_encode_email(the_email)) or if you have devel installed just put the function inside a dsm(). it will put it as a string.
    – cmos
    Commented May 19, 2011 at 6:45

1 Answer 1

1

I'm doing a similar thing, but in a node template. To get the javascript obscured code to return, use the js_entities encoder similar to this:

<?php
$email = render($content['field_email_address']);

// this takes the email address and turns it into a "mailto:" link, otherwise use 'link' => 0
$email_settings = array('link' => 1);

echo "<p>" . invisimail_encoder_js_entities_encode($email, $email_settings) . "</p>";
?>

Also, I use the Quick Javascript Switcher extension in Chrome to quickly toggle js off/on to see if things like this are working:

https://chrome.google.com/webstore/detail/quick-javascript-switcher/geddoclleiomckbhadiaipdggiiccfje

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.