Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2025-02-08 11:47:51

etc
Developer
Registered: 2010-11-11
Posts: 5,318
Website GitHub

Re: Redirect to external articles

phiw13 wrote #339018:

How would that work in practical usage – e.g with the markup given above – article list, external link with rel and/or target attributes, internal links just “plain“.

Dunno. Presently <txp:permlink /> does not accept rel attribute, but sets rel="bookmark". We might imagine that for external links it becomes rel="external" if it fits better. We could also somehow enhance the tag with this attribute.

As for target, themes could use a bit of js to set target="_blank" or whatever for external links. Ideas welcome.

Offline

#14 2025-02-09 06:23:11

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

Re: Redirect to external articles

etc wrote #339024:

Presently <txp:permlink /> does not accept rel attribute, but sets rel="bookmark". We might imagine that for external links it becomes rel="external" if it fits better. We could also somehow enhance the tag with this attribute.

Sounds good to me, and non-contentious if the link is outside the current site_url’s domain.

As for target, themes could use a bit of js to set target="_blank" or whatever for external links. Ideas welcome.

Yes! People have passionate opinions on whether a new tab/window should be spawned, so leave that to the site owner / designer.


TXP Builders – finely-crafted code, design and txp

Offline

#15 2025-02-09 07:38:52

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,300
Website

Re: Redirect to external articles

etc wrote #339024:

Dunno. Presently <txp:permlink /> does not accept rel attribute, but sets rel="bookmark". We might imagine that for external links it becomes rel="external" if it fits better. We could also somehow enhance the tag with this attribute.

As for target, themes could use a bit of js to set target="_blank" or whatever for external links. Ideas welcome.

Adding rel=external by default in such case is a no-brainer I think. target="_blank" should certainly not be set by default, hence I asked above – a way, txp-code-wise to differentiate between the 2 types of <txp:perm_link /> (e.g. being able to something similar to the code snippet given by Stef above).

I am no fan of wasting some js to inserting that attribute…


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#16 Yesterday 19:02:40

etc
Developer
Registered: 2010-11-11
Posts: 5,318
Website GitHub

Re: Redirect to external articles

phiw13 wrote #339031:

I am no fan of wasting some js to inserting that attribute…

That might be

<txp:permlink trim='/\b(rel="external")/' replace='$1 target="_blank"'><txp:title /></txp:permlink>

if you prefer server-side processing. Try it, anyway.

Offline

Board footer

Powered by FluxBB