Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-11-24 07:05:00

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 453
Website

txp:permlink displays html instead of Japanese…

For some articles on my site, there is Japanese in the url, e.g.:

https://www.oldphotosjapan.com/photos/841/上野広小路の風車

I use <txp:permlink /> to display the link in the article, so that readers can quickly get the url when they cite the article.

Now, I get this output:

https://www.oldphotosjapan.com/photos/841/%E4%B8%8A%E9%87%8E%E5%BA%83%E5%B0%8F%E8%B7%AF%E3%81%AE%E9%A2%A8%E8%BB%8A

I want this:

https://www.oldphotosjapan.com/photos/841/上野広小路の風車

I have tried all the txp escapes, but have been unsuccessful.

How do I do this?


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#2 2021-11-27 11:00:21

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

Re: txp:permlink displays html instead of Japanese…

I’m afraid the only option would be to call urldecode function, either via

<txp:php>echo urldecode(processTags('permlink'));</txp:php>

or by registering urldecode in Advanced options and calling

<txp:evaluate test='<txp:permlink />' query="urldecode(<+>)" />

The reason why txp encodes its URLs is that otherwise titles like Yes? No! would generate invalid links in title mode. There is a room for improvement though.

You can also try to construct the links manually, like

<txp:site_url /><txp:section />/<txp:article_id />/<txp:custom_field name="url_title" />

but this would not be URL mode independent.

Offline

#3 2021-11-27 12:51:18

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 453
Website

Re: txp:permlink displays html instead of Japanese…

etc wrote #332030:

I’m afraid the only option would be to call urldecode function, either via

<txp:php>echo urldecode(processTags('permlink'));</txp:php>...

or by registering urldecode in Advanced options and calling

<txp:evaluate test='<txp:permlink />' query="urldecode(<+>)" />...

The reason why txp encodes its URLs is that otherwise titles like Yes? No! would generate invalid links in title mode. There is a room for improvement though.

You can also try to construct the links manually, like

<txp:site_url /><txp:section />/<txp:article_id />/<txp:custom_field name="url_title" />...

but this would not be URL mode independent.

Fascinating.

Thank you very much for the advice! It works perfectly.


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

Board footer

Powered by FluxBB