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: 446
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?


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-12-15 07:41:33

etc
Developer
Registered: 2010-11-11
Posts: 5,028
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: 446
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!


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