Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Creating a link out of a custom field
I’m trying to make a custom field linkable but not quite sure how it’s done. Here’s the code I have:
<code>
<txp:if_custom_field name=“Link”><strong>LINK:</strong>
<a href=”<txp:custom_field name=“Link” /></txp:if_custom_field>” />
</code>
I’m obviously doing it wrong, but not sure how to do it right.
Thanks in advance
Offline
Re: Creating a link out of a custom field
<txp:if_custom_field name="Link"><strong>LINK:</strong>
<a href="<txp:custom_field name="Link" />">link text</a></txp:if_custom_field>
a is a HTML element with a closing tag.
Offline
Re: Creating a link out of a custom field
Hmmm perhaps it’s not possible to make the text a link? I have a custom field called links, when I enter the text in the that field it will display, but using the above code makes the text disappear, when I want it linkable.
Here’s an example of what I’m trying to do – where it says link it should display the text as a link, but the text has disappeared. So is it not possible to make the code a link? I used the following code:
<code>
<txp:if_custom_field name=“Link”><strong>LINK:</strong>
<a href=”<txp:custom_field name=“Link” />”></a></txp:if_custom_field>
</code>
I removed the link text as any text displayed will come from the field that is filled in, if that makes sense.
EDIT: I reverted back to the old code to display the text, still can’t seem to make it linkable :(
Thanks again
Last edited by sekhu (2006-08-13 20:02:27)
Offline
#4 2006-08-13 21:05:39
- NyteOwl
- Member

- From: Nova Scotia, Canada
- Registered: 2005-09-24
- Posts: 539
Re: Creating a link out of a custom field
What about
<code>
<txp:if_custom_field name=“Link”>
<strong>LINK:</strong> <txp:permlink><txp:custom_field name=“Link” /></txp:permlink>
</txp:if_custom_field>
</code>
Obsolescence is just a lack of imagination. / 36-bits Forever! / #include <disclaimer.h>;
Offline
Re: Creating a link out of a custom field
that works a treat NyteOwl, thank you
Offline
#6 2006-08-13 23:30:01
- NyteOwl
- Member

- From: Nova Scotia, Canada
- Registered: 2005-09-24
- Posts: 539
Re: Creating a link out of a custom field
Your welcome, glad I could help.
Obsolescence is just a lack of imagination. / 36-bits Forever! / #include <disclaimer.h>;
Offline
Re: Creating a link out of a custom field
Hi NyteOwl,
That’s a really nice way of incorporating links!
Just one question, I’m using a custom field for an email address, but the code produces a hyperlink rather than an email (mailto:) link. Not all contacts have email addresses, so I’ve used a conditional -
<code>
<tr>
<td><txp:if_custom_field name=“contact_email”>
<txp:permlink><txp:title /></txp:permlink> <txp:else /><txp:title /></txp:if_custom_field></td>
<td><txp:custom_field name=“contact_title” /></td>
<td><txp:custom_field name=“contact_telephone” /></td>
</tr>
</code><br/>
I’ve played with the <code><txp:email/></code> tag, but no luck. Any suggestions?
Offline
Pages: 1