Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to I "uncloak" an email address in Joomla 3.1?

Tags:

php

joomla

I'm currently developing a Joomla module that will be a simple contact us form.
When the form errors out for some reason, I want to retain the data the user input into the various fields so they don't lose what they typed in.

I've been able to make it work for most fields, but email is stumping me.
The reason is Joomla seems to apply email cloaking using Javascript, and when I retrieve the post parameter instead of a plain email address like the user typed, Joomla returns the javascript and sticks that in the field instead.

How do I get the raw email address without the added cloaking?

Here is the code I'm using to retain the entered data in the event the form isn't submitted properly.

<p>
  <label ><?php echo $email ?></label>
  <input type="email" name="email" id="email" 
         value="<?php echo isset($_POST['email']) 
                 ? JFactory::getApplication()->input->get('email','','STRING') 
                 : "Enter Email Address" ?>"/>
</p>
like image 800
Josh Avatar asked Oct 09 '13 00:10

Josh


2 Answers

I finally figured this out. With Joomla to disable email cloaking on a certain page, just insert the following code anywhere in the same article where you want it to be disabled:

{emailcloak=off}
like image 100
Josh Avatar answered Oct 02 '22 22:10

Josh


The cloaking happens via a content plugin called "Content - Email Cloaking" which you can simply turn off in your plugin manager. Another option would be to not parse plugins in your module...

like image 31
Adam B Avatar answered Oct 02 '22 21:10

Adam B