Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-12-02 15:16:49

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

<txp:permlink>, but with a select URL format

Say a Textpattern site uses /section/id/title/ for its article permlink format…but I want to find the /section/title/ equivalent URL stub (i.e., no id in the mix), what’s the sanest way to do this, please? Is there some hidden magic in permlink?

This is a bloody good CMS, I really should learn it some day.

Last edited by gaekwad (2020-12-02 15:25:37)

Offline

#2 2020-12-02 17:05:32

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: <txp:permlink>, but with a select URL format

You can do it either on a per section basis presentation>sections>click on section or globally in preferences.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2020-12-02 18:13:31

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: <txp:permlink>, but with a select URL format

Thanks, Yiannis. I should have explained more clearly.

I’m using <txp:article_custom /> with an article form that uses <txp:permlink />. What I’m wondering is whether it’s possible to override the site’s (or selection’s) chosen URL slug type within <txp:permlink />, something akin to (bogus code, won’t work):

<txp:permlink urlmode="section-title" />

…and for this to output the ‘/section/title’ permlink instead of whatever the site or section is set too.

I managed to bodge a way around it for now, but I’m curious as to whether it’s possible.

Offline

#4 2020-12-02 20:34:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: <txp:permlink>, but with a select URL format

Not possible automatically as far as I’m aware at the moment. The <txp:permlink /> tag will set its output to the URL scheme of the matching section in which the destination content resides. I can’t see a concrete reason to bypass this, since doing so may invalidate the URL. What’s your use case for this functionality?

Possible exceptions are messy mode which works all the time anyway, and sometimes variants of /section/id can work without the title, since by the time the ID is known, the article title is a formality and is (internally) ignored in favour of the ID.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2020-12-02 21:18:31

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

Re: <txp:permlink>, but with a select URL format

gaekwad wrote #327206:

Say a Textpattern site uses /section/id/title/ for its article permlink format…but I want to find the /section/title/ equivalent URL stub (i.e., no id in the mix)…?

I just build the urls manually in such cases, e.g.:

</txp:site_url /><txp:section/>/<txp:article_url_title />

The question is whether your section then recognizes that. I’ve forgotten exactly, but some url schemes will, I believe, recognize the standard section/article-url-title schemes.


TXP Builders – finely-crafted code, design and txp

Offline

#6 2020-12-02 21:29:15

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: <txp:permlink>, but with a select URL format

Yep, building them manually should work fine if there’s a unique title. In the event there’s a duplicated title, all bets are off (well, okay, you get the first, probably. Or the last. Uhhh, yeah, dunno. All bets are off).

Beyond messy mode, /section/title is the most permissive format as it’s the one we try hardest to match regardless of how mangled the URL seems. If there’s a matching article in the section, we’ll try and return it even if the permlink scheme is something else. But if you add a trailing slash then this behaviour is stopped because it’s deemed to be a landing page.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB