Encode email in Wygwam?
Is there a way to encode an email address that's output as a mailto: link with a config setting or even using an EE plug-in? I tried a few and had no useful success.
-
I see in Wygwam 2 there's an option in the field config advanced settings to set "emailProtection" to "encode". I haven't had any success in making this actually encode though.
-
-
Does Wygwam actually respect EE's email encoding? I have inline emails in Wygwam fields that are displayed in the HTML with the mailto: link. This seems like a very serious oversight -- am I wrong?
-
-
If you insert the following:
{encode=email@domain.com}
(no quotes) directly in the Wygwam field, it works. -
-
Sorry for not responding to this sooner.
That works, and also setting that emailProtection advanced setting in Modules > Wygwam > [your config name] will also work. Either way you’ll need to re-save your entries before the change takes effect. -
-
Hi, The {encode} trick is not working for me, and also the advanced setting (email protection) is also not working. I am using WYGWAM 2.2.2 and EE Version 2.1.3 Build 20101220 (the latest).
Help? -
-
-
yes, i saved them. any other suggestions?
-
-
-
-
-
Hi Brandon! Yes, I resaved the entry. I even tried using both the encode AND the email protection setting at the same time, but it won't work.
-
Any other ideas?
-
-
-
-
-
Hi sorry to be here again, I wonder do you have any ideas about the problem I'm describing? It is strange that the 2 fixes you propose are not working for me.
-
-
I'll second that none of the fixes are working apart from writing {encode=email@example.com}... I would rather it was automatic for clients.
-
-
Hi Rory,
I saw in your other thread that you’re still on Wygwam 1.x. Can you please update to Wygwam 2? Lot of things have been tweaked and fixed since then... -
-
Brandon, for this issue (there are 2 separate ones, on separate sites), I am on wyg 2.2.2. This is for the law site I emailed you about.
-
-
If you want to use Wygwam's / CKEditor's email encoding capabilities, you need to set the emailProtection to "encode" under advanced settings AND you need to create the link through the Wygwam link dialog by setting the link type to "E-Mail". That is the only way the encoding method actually runs.
If you want to use EE's built in encoding tag, you can simple place {encode=name@domain.com} directly into the Wygwam field.
You'll need to view source to verify encoding is working. EE wraps the link around a span with a randomly generated ID and includes some encoding JavaScript immediately afterwards.
Wygwam / CKEditor includes the JavaScript encoding inline within the href.
Hope that helps. -
-
OK, so when I set the emailProtection to "encode" in wygwam's advanced settings AND I create an email link using the link button, it still doesn't hide the email address because I need to display it on the page itself. In other words, I want to show:
me@mydomain.com
...on the page and have it function as a link. So, right now the rendered code shows this:
me@mydomain.com
To be clear, I typed in the email address into wygwam, selected it, clicked the link button and set the type to email link, put the email address into the email field in the dialog box. And it renders the above, exposing the email 2 times.
Next: If I turn OFF the emailProtection in the wygwam settings, and use this text in my wygwam field:
{encode=name@domain.com}
(now I have NO link set up using the link button, just the code above), I get this in my rendered code:
me@mydomain.com
So, something seems very wrong, no? If I am doing something wrong, please let me know.
If I use the email protection setting AND the {encode=email@domain.com} thing, I get all the javascript showing on the actual web page, and the email itself is properly encoded. But of course who wants all that stuff showing up (at the top of the page).
If you can see what I'm doing wrong, I'll be so glad to hear it! Thanks. -
-
In both cases when you say "rendered code", are you looking what is displaying in the browser or are you viewing source to see the actually HTML being rendered?
-
-
I mean in both cases the source code, the actual HTML code (not what you see in the browser). For example, I set the email protection setting to "encode" and I created 2 email links using the wygwam link button. One wraps the email (as text) in an email mailto: link. The other wraps the word "test" in an email link.
Here's that rendered HTML code:
me@test.com
test
As you can see, the first exposes the email address 2 times. The 2nd one works, it encodes the email. I had not thought to try this, it does work. But I do want to visually show in the browser window, the actual email address, and have it link to send an email. Is this possible?
In other words, I want you to see the actual email address in the web page, and you can click on it, and it creates an email message.
As explained, when I use {encode=me@test.com} I get the javascript showing up in the browser window, at the top of my web page.
Thanks. -
-
Can you send some Super Admin credentials to brad@pixelandtonic.com so I can see exactly what the generated code is on your end or paste the HTML snippets using pastie.org? I suspect Get Satisfaction is stripping a lot of what you're trying to explain in the links.
-
-
-
-
" But I do want to visually show in the browser window, the actual email address, and have it link to send an email. Is this possible?"
I'm not sure I understand that sentence.
The only odd thing I see happening is that when you create a mailto link with emailProtection on and you don't have text selected, it defaults to using the email address as the text and it shows in the browser status bar (when you hover over the link) as the email address.
When you create a mailto link with emailProtection on and you DO have text selected to create the link on, when you hover over the link, the browser status bar shows the JavaScript encoding.
If this is what you're talking about, then it's a CKEditor bug.
In both cases, the links work fine and opens your default email client with the To: address filled in properly and they are both properly encoded in the HTML code fine. -
-
Hmmm. I am looking at the contact page for this site:
http://bit.ly/guat9P
...and I see in the rendered HTML code ("view source") that the text which appears in the middle of the page (the contact info), which is coming from the wygwam field, does NOT have the email address encoded. You can plainly see it in the rendered HTML for the link above. You need to look at the part of the code that shows the main content box of the page (not the header, which also has the email address, which is properly encoded, and is not coming from a wygwam field).
I have that rendered HTML code here, as well as some other code & info:
http://pastie.org/1792545
My understanding is that if the email address is "encoded", then it doesn't show in the rendered HTML (source) code. As it is now, spammers can read that email address.
In EE's native encoding, the email address does not appear at all in the code that would generate this link, not in the href, and not the text that is contained between the open & close a href tags (which in this case is the email address itself). This is what his happening with the non-wygwam field that generates the email link in the page's header. I included that snippet of HTML in the same pastie.
The output from wygwam does have some javascript, but it is not hiding the email address, it is right there, readable. Right?
I was not referring to the stuff you mention above about the browser status bar & whether or not text is selected when you create a mailto link.
Here is what I mean by:
"But I do want to visually show in the browser window, the actual email address, and have it link to send an email. Is this possible?"
I want the email address (me@mysite.com) to be readable text in the browser window, just like any other text. And it has a mailto: link on it. The text you click on *is* the email address. Just like it shows on the web page we're talking about. I need both the email that is in the "mailto" link AND the text that is wrapped in that href (the email address) to both be encoded.
I do hope that is clear; I really think that this email is not being encode, while you say that it is, and I'm totally confused. -
-
Ahh... I see what you're saying. Give me a bit to look into it.
-
-
Rory,
Go to: Admin > Channel Administration > Channels > Edit Preferences > Channel Posting and set "Automatically turn URLs and email addresses into links" for your contacts channel.
Should work fine then. -
-
Hi, That setting is set correctly for the "static_pages" channel, which is the correct channel for the entry in question (contacts, #4).
-
-
Sorry... I meant static_pages channel and set it to "no". My bad.
-
-
Hmm. Getting closer. No more double link tags, and the email in the href tag is encoded. But, the email text (the text between the open/close anchor tags is the email address) is still not encoded, it's still exposed. I resaved the entry. I redid the link tag to be sure there was no gunk in there. Do you think we can get that encoded too? That's what the native EE encoding does. Can I get that working even though we are in a wygwam field?
-
-
It looks like CKEditor only encodes what's in the href portion of the link. It'll have to be something we look at extending and adding to Wygwam.
-
-
Oh. No way to get the native EE encoding working here?
If not, I'll use some workaround here, because I don't want the email address exposed. -
-
EE encoding is dumping the extra information at the top of your page because you're using the Wygwam {about_main_text} in the of the page in your template. Take that out and it should work.
-
-
Oh my goodness, that was it. That darn field up in the embed statement at the top (which was writing in stuff to my meta description) was messing everything up. Holy cow, what an epic crisis! So, I am just going to use a conditional to take that on this page, and I should be good to go. Whew! Thanks for seeing this through, it was a bit of a pain for you I'm sure! Thanks!
-
-
-
-
Brad, just trying to work this as well. Have a client that would like email addresses to be displayed as such in content, but the emailEncode function in the CKEditor advanced settings is only encoding that which is inside the URL.
Am I to understand that this is about as much encoding as it will do at the moment? -
-
Hi Brendan,
What is your Admin > Channel Administration > Channels > Edit Preferences > Channel Posting -> "Automatically turn URLs and email addresses into links" set to?
Thanks,
Brad -
-
I have it set to off at the moment so although the href is encoded, the text between the anchor tags is not. Not ideal really, and sort of pointless.
-
-
Hi Brendan,
Yeah, that's way CKEditor does email encoding by default. I agree not really ideal. The other option is to put {encode=name@domain.com} directly into the Wywgam field and use EE's built in encoder.
Brad -
-
Hm, I thought I had tried that as well. What would the settings need to be for that to work as expected?
-
-
As far as I know, nothing... here is the documentation on EE's site: http://expressionengine.com/user_guid...
-
Loading Profile...


Twitter,
Facebook, or email.

EMPLOYEE

