Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2010-09-24 13:32:20
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,304
Encode txp:title for use in a mailto link
Just wanted to ask here, but then suddenly succeeded myself. So I’ll post the solution instead. For the remaining mini question: see below.
I need to put some txp:titles containing blanks, umlauts and accented characters into a mailto link. The following line does the job as good as it seems feasible:
<txp:php>echo(rawurlencode($GLOBALS['thisarticle']['title']));</txp:php>
Some little “hooks” and crescents esp. from turkish characters come out as separate letters, though (Ş as S¸, ğ as g˘ etc.). Is it possible to throw another function into the mix to remedy that?
Last edited by uli (2010-09-24 14:10:32)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Encode txp:title for use in a mailto link
Hello Uli
I am hoping to find a way to insert the title of whatever the current article happens to be into any mailto link, and I stumbled on this old post of yours.
Thank you!
But I don’t quite understand where I put my actual email address…?
Strictly Amateur
Offline
Re: Encode txp:title for use in a mailto link
Try the email tag and put Uli’s code in its container. Although these days you might be able to use the supercharged escape attribute thusly:
<txp:email email="donald.swain@example.com">
<txp:title escape="url" />
</txp:email>
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Encode txp:title for use in a mailto link
Thank you Bloke. I tried that (both your suggestions) and it outputs an ugly link:
Send me an email and I’ll send you the payment link:
%22Granville%20Point%2C%20Childs%20Hill%20%28evening%29%22
This is the code on the page:
<txp:email email="xx@xxxx.org">
<txp:php>echo(rawurlencode($GLOBALS['thisarticle']['title']));</txp:php>
</txp:email>
Strictly Amateur
Offline
Re: Encode txp:title for use in a mailto link
John-Paul F wrote #331641:
it outputs an ugly link:
Hehe, yep. That’s what the ‘raw’ encoding does. It’s for making links that would otherwise be mangled by weird encoding or odd characters. If you don’t need all that, just output the title as normal for a cleaner link:
<txp:email email="donald.swain@example.com">
<txp:title />
</txp:email>
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Encode txp:title for use in a mailto link
Thank you Bloke.
That’s perfect.
Strictly Amateur
Offline