Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-09-04 20:52:10

freshface
Member
Registered: 2006-08-23
Posts: 49

Category name with "&" entity problem

Hey,

I haver a category where and ampersand is in it “&” but when I show the category (with Article category title) in the articles it stays an &.
How can I make it and <code>&amp;</code> so my page validates correct?

Last edited by freshface (2006-09-04 20:53:13)

Offline

#2 2006-09-04 21:07:32

Zanza
Plugin Author
Registered: 2005-08-18
Posts: 699
Website

Re: Category name with "&" entity problem

I also have a similar category, “black & white”. I used this solution: in the name category I use “black-and-white”. In the title I typed “black &amp; white”, that is converted in numeric entity & # 3 8 ; so that no validation issue is encountered. May this help you?

Z

Offline

#3 2006-09-04 21:10:04

freshface
Member
Registered: 2006-08-23
Posts: 49

Re: Category name with "&" entity problem

It’s a solution thx, but I would like the & because clients add the categories.
I will search further.

Offline

#4 2006-09-04 21:24:46

NickML
Member
From: Scotland
Registered: 2006-05-14
Posts: 58
Website

Re: Category name with "&" entity problem

Haven’t tested it, but this should work for writing the category in a compliant style.

<code>
<txp:php>
$c = category(array());
$oldWord = “&”;
$newWord = “&amp;”;
$c = str_replace($oldWord , $newWord , $c);
echo $c;
</txp:php>
</code><br/><br/>

~Nick

Offline

#5 2006-09-04 21:31:20

freshface
Member
Registered: 2006-08-23
Posts: 49

Re: Category name with "&" entity problem

Where do I need to put the php code?
In the form?

Last edited by freshface (2006-09-04 21:31:40)

Offline

#6 2006-09-04 21:34:35

freshface
Member
Registered: 2006-08-23
Posts: 49

Re: Category name with "&" entity problem

When I replace the & with 38 en replace back the 38 in & it validates good.
Without the php code.

Offline

#7 2006-09-04 21:36:26

NickML
Member
From: Scotland
Registered: 2006-05-14
Posts: 58
Website

Re: Category name with "&" entity problem

Wherever you currently output the category name. I’m not confident about the second line, however, so it may not work.

~Nick

Offline

#8 2006-09-04 21:38:14

freshface
Member
Registered: 2006-08-23
Posts: 49

Re: Category name with "&" entity problem

It don’t work, thanks for your effort :)

Offline

#9 2006-09-04 22:24:06

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Category name with "&" entity problem

If you’re going to escape, then go all the way:
<code><txp:php>echo htmlspecialchars(category(array()));</txp:php></code> (not tested)

Isn’t this a bug? If so, perhaps it can be fixed in 4.0.4…

Last edited by ruud (2006-09-04 22:24:35)

Offline

#10 2006-09-05 06:19:51

freshface
Member
Registered: 2006-08-23
Posts: 49

Re: Category name with "&" entity problem

I think I wil add htmlspecialchars in the php file that writes to the database.

Offline

Board footer

Powered by FluxBB