This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Learn » eZ Publish » Encapsulating e-mails for usability...

Encapsulating e-mails for usability and spam protection

Tuesday 26 October 2010 10:15:03 am

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Step 1 : Setting up template.ini.append.php

Recently I wanted to make e-mail addresses "uncatchable" at a site to avoid crawlers that collect them, a solution was to configure sitesettings/your-site/template.ini.append.php and add under [WashSettings] the following:

# Replacements strings for the . and @ in an email
# Used to display emails in a way that SPAM engines
# cannot fetch automatically
EmailDotText= [punto] 
EmailAtText= [@]

Adding such definitions e-mail addresses become something like "myname [@] domain [punto] com", you can also change it to the conventional "at" and "dot".

Hint: You can leave spaces before and after each definition “ [punto] ” or “ [@] ” to achieve spaces within the e-mail sequence

The code generated as html by eZ Publish looks something like this:

<a href="mailto:myname@domain.com">myname [@] domain [punto] com</a>

This kind of sequence for an e-mail addresses is not always a straight-forward solution. Avoiding the mailto also keeps crawlers away, so with some jQuery code we can obtain a more interesting approach. You can still let the eZ Publish kernel handle the e-mail address generation but this time surrounded by the <div> that jQuery code will then handle later on when the page has loaded.

An example of template code :

{$owner_map.user_account.content.email|wash('email')}

Will generate something like this:

myname [@] domain [punto] com

Wrapped around the div and adding an id, this will become:

<div id="mail">myname [@] domain [punto] com</div>
 
36 542 Users on board!

Tutorial menu

Printable

Printer Friendly version of the full article on one page with plain styles

Author(s)

Proudly Developed with from