Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: [issue] Special HTML characters (<, >, &) in article titles
> zem wrote:
> maniqui: it’s still not clear to me what you’re proposing. Send us some code that does what you’re suggesting and we’ll take a look at it.
Sorry, “pale face”, me not speak very good english ;)
I will try to summarize:
In TXP 4.0.1, it was posible to use HTML elements (acronym, strong, em, etc) in the article titles (and even in section/category titles). And that was a nice feature that now we dont have in 4.0.2.
Now (4.0.2), if you use HTML elements in titles, the < and > are escaped and so, you get article titles like “I love < abbr title=“Textpattern”>TXP< /abbr>”, when before (4.0.1) you got a nice title like “I love <abbr title=“Textpattern”>TXP</abbr>”.
The same applies to section/category titles. Before, you can use HTML elements in them, now you cant (and that was very very cool, because it added lot of flexibility… think: you can have spans or strong tags in the section title!)
So, as I see it, TXP have lost an interesting feature.
And as far as I understand, TXP lost that feature for one reason: to have valid content in the <code><title></title></code> tag.
You cannot use a > or a < in the <code><title></code>, but you can have <code>&lt;</code> or <code>&gt;</code>
And the problem started when someone used <code><txp:page_title /></code>.
In an individual article context, that txp tag will include the article title in the <code><title></code> tag.
So, if you have a title like “a > b”, you will get invalid code (a warning) if the “>” is not escaped in the <code><title></code>.
So, between 4.0.1 and 4.0.2, the change was to escape any > and < in article/section/category title. The result: now you have valid content in <code><title></code> but you cant use HTML elements in article/section/category titles. In 4.0.1, “out of the box”, if you use HTML elements you will get invalid content in title element, but that is why I wrote the tip about using sab_striphtml to strip HTML elements from any article/section/category title.
My thoughs/suggestion: how many users use < and > in the article titles? how many users writes formulae in article titles? I dont know, but I would bet they are just a minority.
Of course it’s nice to write formulae symbols in article titles, but if you want to do that, then manually encode your special characters. Write <code>&lt;</code> instead of typing <, write <code>&gt;</code> instead of > and etcetera.
That way, if you revert back to the behaviour of 4.0.1, you can use the HTML elements in article titles (and strip them from the <code><title></code>). Also, when you need to use special characters in titles (< > and many more) you type them as HTML entities references.
I think I have been not very clear again… ¿no?
Next time I will try to write no more than two paragraphs, I promise.
Thanks!
Offline
#26 2005-11-14 04:43:03
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: [issue] Special HTML characters (<, >, &) in article titles
Sorry, “pale face”, me not speak very good english ;)
Your English isn’t the problem. Forgive my stubborness, I’m trying to find the “what” amongst the “why”.
TXP lost that feature for one reason: to have valid content in the <title></title> tag.
Don’t forget feeds. And remember, entities that are valid in HTML aren’t necessary valid in XML.
My thoughs/suggestion: how many users use < and > in the article titles? how many users writes formulae in article titles?
How many use HTML in article titles? (This I don’t know either, but I do know we received more reports about the lack of encoding prior to 4.0.2, than we have about the presence of it now)
Now, if you were arguing for Textile in article titles, we might be on to something.
Alex
Offline
Re: [issue] Special HTML characters (<, >, &) in article titles
zem wrote:
Now, if you were arguing for Textile in article titles, we might be on to something.
Hey, I made that request months ago !
;->
Last edited by Jeremie (2005-11-14 05:22:55)
Offline
Re: [issue] Special HTML characters (<, >, &) in article titles
Ok, after a frustrating time with an & character in my title. I found the following approach to work.
<code><title><txp:php>echo htmlspecialchars(page_title());</txp:php></title></code>
Am I missing something? Is there a good reason why this is bad? At least it validates now.
Aside: Oddly enough I found the solution ‘htmlspecialchars()’ from zem’s excellent “how to make a plugin” series, otherwise I’m a complete php dozer.
Last edited by mrdale (2006-03-24 19:04:59)
Offline
#29 2011-08-02 23:39:13
- wavesource
- Member
- From: Australia
- Registered: 2011-08-02
- Posts: 56
Re: [issue] Special HTML characters (<, >, &) in article titles
This is an old thread, but I found this solution useful, building on mrdale’s comment, allowing me to push HTML to a title in a specific form:
<txp:php>echo html_entity_decode(str_replace(‘ ’,’ ‘,title()));</txp:php>
Offline
#30 2011-12-29 23:23:20
- NyteOwl
- Member
- From: Nova Scotia, Canada
- Registered: 2005-09-24
- Posts: 539
Re: [issue] Special HTML characters (<, >, &) in article titles
Is this issue still afloat? I hacked my old 4.0.3 so that I could use ampersands in the article titles directly. (I don’t use Textile)
Obsolescence is just a lack of imagination. / 36-bits Forever! / #include <disclaimer.h>;
Offline