Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-10-20 17:46:27

Niconemo
Member
From: Rhône-Alpes, France
Registered: 2005-04-18
Posts: 557

Another version of txp:email tag

Here is a problem I have for almost every site :

If we have an adresse book, for example (one person per article), It seems logical to use a custom field to store the e-mail adress… but then we can’t use txp:email tag becaus tags can’t be nested like this, of course :

<code><txp:email email=”<txp:custom_field name=“eMail”/>” linktext=“Send me a mail” title=“Send an Email” /></code>

Some tags exists in 2 versions to do someting like this…

<code><txp:email linktext=“Send me an Email” title=“Send an Email” /><txp:custom_field name=“Email”/></txp:email></code>

I think it would be very interesting with that particular tag, no ?


Nico

Offline

#2 2005-10-20 20:02:43

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Another version of txp:email tag

Would rss_if_author do a good deal of this work for you?


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#3 2005-10-21 05:14:49

Niconemo
Member
From: Rhône-Alpes, France
Registered: 2005-04-18
Posts: 557

Re: Another version of txp:email tag

I don’t think so (thanks anyway) ;) I wasn’t clear it seems…
It’s not about the author : it’s about every other e-mail adresses…
The way the tag is made now it can only be hardcoded : impossible to use a custom field within it

I can’t believe nobody else have to use e-mail links… o_O

E-mail links can be used (disconnected to article authors) in adress-books, event manager, contact pages…
I’ll try to find a php way do do that for me, but I thought that could be useful for more people… maybe not.
Maybe it’s just a job for a plugin… But as the function is ever written I thought a little change was possible in the way the tag works

:-)

Last edited by Niconemo (2005-10-21 05:23:32)


Nico

Offline

#4 2005-10-21 05:27:33

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: Another version of txp:email tag

If you are ready to display an email in html, why don’t you construct the link by hand ?

<code><a href=“mailto:<txp:custom_field name=“Email”/>”>mail the author</a></code>

?

Offline

#5 2005-10-21 07:37:40

Niconemo
Member
From: Rhône-Alpes, France
Registered: 2005-04-18
Posts: 557

Re: Another version of txp:email tag

> Jeremie wrote:
> If you are ready to display an email in html (…)

I’m not. I know what you mean : current crypting solution isn’t the best but there is one and perhaps there will be a better one later (?)

If it was me there would be just no e-mail, only forms… but I’m not the boss.

Anyway I could find a solution each time.

It seems textpattern is mostly used as a blog so I understand this feature is not so important. ;-)


Nico

Offline

#6 2006-03-02 23:01:44

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Another version of txp:email tag

Following zem’s tip in the FAQ I got this to work as follows: It looks nasty in the form but works just fine:

<code><txp:php>$tmpemailstr = custom_field(array(“name”=>“member_email”));echo email(array(“email”=>”$tmpemailstr”,“linktext”=>”$tmpemailstr”,“title”=>“Email “.$thisarticle[‘title’]));</txp:php></code>

results in the content of the custom field “member_email” being written into a temporary string, this is then fed into the <code>txp:email</code> function as the value for email and for linktext with the title field being “Email <code><txp:title /></code>”. You can of course use other values for linktext or title.

As the <code>txp:email</code> function stands it doesn’t convert linktext into entities so if you use the email for the linktext it will be out in the open. This can be solved by adding one line to the <code>function email($atts)</code> in <code>taghandlers.php</code> as follows:

Before the line beginning <code> if($email) { $out = array( …</code> add the following line

<code>if ($linktext == $email) { $linktext = eE($linktext); } </code>

which equates to “if linktext is the same as email then convert it to entities too”. If it’s not the same the linktext is not converted.

Last edited by jakob (2006-03-02 23:04:29)


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB