Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-12-15 07:10:45

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

Space in custom fields

I use values from custom fields in urls. Many of the values contain spaces. For example “Mount Fuji”.

Unfortunately, this doesn’t validate:

Bad value https://www.oldphotosjapan.com/photos/?location=Mount Fuji for attribute href on element a: Illegal character in query: space is not allowed.

I also use these values as regular text, so can not add a hyphen or %20… Besides, it would be impossible to make sure that all potential users add that to the values.

Any ideas for fixing this?


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#2 2021-12-15 07:41:33

etc
Developer
Registered: 2010-11-11
Posts: 4,586
Website GitHub

Re: Space in custom fields

You can try escape="url":

<txp:custom_field name="my_cf" escape="url" />

Offline

#3 2021-12-15 10:04:25

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

Re: Space in custom fields

etc wrote #332227:

You can try escape="url":

<txp:custom_field name="my_cf" escape="url" />...

Thanks. That works perfectly!


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

Board footer

Powered by FluxBB