Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How can I get <txp:title /> to escape the ampersand?
I have an ampersand in the title field of an article:
This is a post about this & that thing
I use the <txp:title />
tag to get it into the page:
This is a post about this & that thing
Is there a way to get Textpattern to escape the ampersand between “this” and “that”, so that it comes out as a valid &
?
I could wrap every instance of txp:title
in upm_textile, but that seems like overkill.
Offline
#2 2009-05-21 14:14:17
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How can I get <txp:title /> to escape the ampersand?
johnstephens wrote:
I could wrap every instance of
txp:title
in upm_textile, but that seems like overkill.
A similar solution can be found here, it’s an old thread but I don’t think the way Txp handles titles has been changed since then.
Offline
Re: How can I get <txp:title /> to escape the ampersand?
Thanks, Els; that’s useful.
My question is when would you every want to display an un-encoded ampersand?
I may use <txp:title />
in a variety of places— header elements, article lists, tabular data, et cetera— but if a client updating their site uses and ampersand in their title, they get invalid output. Unless every single instance of <txp:title />
is wrapped in the Textile plugin or Mr. Dale’s method.
Hmmm.
Offline
Re: How can I get <txp:title /> to escape the ampersand?
I don’t understand how you’re getting unencoded ampersands in the title in the first place. When you save an article they should be encoded.
Code is topiary
Offline
Re: How can I get <txp:title /> to escape the ampersand?
jsoo wrote:
When you save an article they should be encoded.
I agree— that would be my expectation. But that’s not what is happening here: check out this test page . Test page removed
EDIT: Very strange, I added some text to the body, clicked save again, and the ampersands got encoded.
Last edited by johnstephens (2009-05-22 13:20:57)
Offline
Re: How can I get <txp:title /> to escape the ampersand?
I can’t reproduce the problem now; I guess it was just a fluke that I got an unencoded &
. I only noticed it when I ran it through the validator, and when I re-saved the article it got encoded.
Offline
#7 2009-05-22 11:27:03
- immarabi
- Member
- Registered: 2008-04-29
- Posts: 57
Re: How can I get <txp:title /> to escape the ampersand?
This happened to me, actually, when I had zem_reborn print the <txp:title /> of an article in an email. The ampersand would not be escaped and all the quotes also. But when I unchecked the “Prevent widowed words in article titles?” it solved the problem.
Offline