Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
how to add target="_blank" to links please
Hey!
How do I add target=”_blank” to my links please?
(using the <txp:link><txp:link_name /></txp:link>
)
or how do I use only the link url and not the all <a> tag?
Thanks, and have a great weekend you all =)
Offline
Re: how to add target="_blank" to links please
You can’t with TXP tags because it isn’t valid XHTML. To use that attribute you would need to code the links yourself.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: how to add target="_blank" to links please
can I change the code that txp produce and add target blank as default please?
Offline
Re: how to add target="_blank" to links please
You could use a form like this:-
<a class="thislink" href="<txp:link_url />" target="_blank"><txp:link_name escape="html" /></a>
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: how to add target="_blank" to links please
ohh LOL
if the option <txp:link_url />
was in the forms page under “Links”:
Link
Link, title=Description
Link Name
> Link Url
Link Description
Link Category
Link Date
I wasn’t opening this topic
it’s good if it will be in the TXP v.4.0.7
;)
thank you bomb! =)
Offline
Re: how to add target="_blank" to links please
You can also use the plugin zem_prblock. See an explanation of how to do it here. It’s towards the bottom of the page.
Offline
Re: how to add target="_blank" to links please
Now I didn’t know it did that Joe. Not that it is something I need.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Offline
Re: how to add target="_blank" to links please
thebombsite wrote:
You can’t with TXP tags because it isn’t valid XHTML.
To make it valid use JavaScript. In example you could hook external links to rel
value external.
<a rel="external" href="<txp:link_url />"><txp:link_name /></a>
And the jQuery using javascript:
$(document).ready(function(){
$('a[rel="external"]').each(function() {
$(this).attr('target', '_blank');
});
});
Last edited by Gocom (2008-10-25 19:58:23)
Offline
#10 2008-10-25 21:09:35
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: how to add target="_blank" to links please
thebombsite wrote:
You can’t with TXP tags because it isn’t valid XHTML.
This is one of the main reasons I created adi_link.
Put <txp:adi_link ext_link="1" />
in the link form. This will generate something like:
<a href="http://textpattern.net/" title="TextBook" rel="external" class="ext_link">TextBook</a>
and then use some javascript to do the “open in a new window” bit. For this, I’ve used code from Sitepoint. The class can be used to style the link to make it look different (e.g. show the ‘arrow pointing out of a square’ graphic).
This way you get valid XHTML and links opening in a new window.
Offline