Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-10-25 15:09:54

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

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

#2 2008-10-25 15:19:14

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

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

#3 2008-10-25 15:23:09

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

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

#4 2008-10-25 15:37:42

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

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

#5 2008-10-25 15:55:28

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

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

#6 2008-10-25 16:00:57

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

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

#7 2008-10-25 16:25:13

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

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

#8 2008-10-25 16:53:22

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: how to add target="_blank" to links please

What about Gocom’s URL link plugin?

Offline

#9 2008-10-25 19:57:48

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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

Board footer

Powered by FluxBB