In the current version there does not appear to be a way to select the User: E-mail field in Views and have it be obfuscated by SpamSpan. As a workaround I'm using the following code in a Views footer, but I have to turn on the PHP filter, which is not ideal:

 $node = menu_get_object();
$user = user_load($node->uid);
print spamspan($user->mail);

Thank you for your consideration, and for a great module!

Comments

Wolfgang Reszel’s picture

Status: Active » Needs review

Hi,

I don't know if it is the best solution. I added the following functions to spamspan.module so it affects every mailto-link which is rendered by theme_link().

function spamspan_theme_registry_alter(&$theme_registry) {
  $theme_registry['link']['function'] = 'spamspan_link';
}

function spamspan_link($variables) {
  if (preg_match('/^mailto:/', $variables['path'])) {
    return spamspan(preg_replace('/^mailto:/', '', $variables['path']));
  } else {
    return theme_link($variables);
  }
}
Anonymous’s picture

How to change code #1 so it can moved to the template.php?

Let me ask it different. Is there a way to have all mailto links in the webpage (views, blocks , ..) protected by spamspan with some code in the template php file?

Anonymous’s picture

Issue summary: View changes

I'ld also like to second this as an issue, most of my email addresses are not in the content, but rather in a view block. It would be great to be able to run this on those blocks as well. This view blocks aren't using a filter on say the User->email address link.

---------
Never mind I found the spamsan display filter on the email link. sometimes I can't see past the problem.

http://drupal.stackexchange.com/questions/38595/obfuscating-email-addres...

peterx’s picture

Status: Needs review » Closed (fixed)

I added a page to the documentation. The Email Field module could add a similar page to their documentation.

jennypanighetti’s picture

Status: Closed (fixed) » Active

I'm still having an issue with this. I have a plain text field that is being used for an email address, and it's doing a rewrite before passing the results on. I do not see Spamspan in the "Formatter" dropdown, and Spamspan is NOT being applied on the end result display block.

jennypanighetti’s picture

Version: 7.x-1.1-beta1 » 7.x-1.2
hanskuiters’s picture

I managed to get this working in a custom view template for the mail field.

Go to [path to your modules]/views/theme and copy the file views-view-field.tpl.php to you theme folder.
Change to name of that file to views-view-field--mail.tpl.php.
In that file change:
print $output;

to:

  if (function_exists('spamspan')) {
    print spamspan($output);
  }

Clear cache at /admin/config/development/performance

nattyweb’s picture

Thanks HansKuiters - most helpful and I can report this worked well for me. I made a slight alteration in case I disabled the module in future:

  if (function_exists('spamspan')) {
    print spamspan($output);
  }else{
    print $output; 
  }
benstallings’s picture

Status: Active » Closed (outdated)

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.