Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-04-22 00:49:20

moslib
Member
Registered: 2005-08-11
Posts: 39

RSS feeds and ampersands in titles

“Prevent widowed words in article titles?” – YES

This is great – but what about when creating a custom RSS feed output? … I’ve escaped the ampersands (using <txp:atb_html_special_chars>), but the feed validator says “title should not contain HTML”…

Is there any way to remove the widow preventer in this particular instance?

Or is a bit of HTML like that in the title no big deal?

thanks

Offline

#2 2008-04-22 08:40:37

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

Re: RSS feeds and ampersands in titles

You’d have to do the exact opposite: unescape the already escaped ampersand instead of escaping an escaped ampersand.

Offline

#3 2008-04-22 09:44:08

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

Re: RSS feeds and ampersands in titles

Patch to fix this in article titles:

--- rss.php	(revision 2859)
+++ rss.php	(working copy)
@@ -82,7 +82,7 @@
 						$count = ($comments_count > 0) ? ' ['.$comments_count.']' : '';
 					} else $count = '';

-					$Title = htmlspecialchars(strip_tags($Title)).$count;
+					$Title = escape_title(strip_tags($Title)).$count;

 					$thisauthor = get_author_name($AuthorID);

fixed in SVN changeset 2861

Last edited by ruud (2008-04-22 09:52:58)

Offline

#4 2008-04-22 23:45:01

moslib
Member
Registered: 2005-08-11
Posts: 39

Re: RSS feeds and ampersands in titles

Ruud, this fix applies if you’re using Txp’s built-in feeds capability, right?

I’m using a page template – with the <txp:mg_setheader /> tag to set the content type to ‘text/xml’

Reason – to provide an events listing that’s based on the chronological order of events, rather than when they were inputted into Txp. It’s also used for other content items that are time-based and handled with zem_event, but need to be shown in a similar chronological order, and removed when the ‘event’ has expired.

Maybe I should try another plugin to strip HTML – that might be the simple solution… will go try…

EDIT: nope doesn’t work. Probably need some custom code or plugin to specifically replace the &#160; with a single space while at the same time converting any ampersands in the title

going round in circles here!

Last edited by moslib (2008-04-23 00:06:44)

Offline

#5 2008-04-23 00:55:03

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: RSS feeds and ampersands in titles

Hi moslib,

try no_widow="1" in the <txp:title /> tag.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#6 2008-04-23 01:42:10

moslib
Member
Registered: 2005-08-11
Posts: 39

Re: RSS feeds and ampersands in titles

Thanks Maniqui – I don’t see any difference in the output though. And looking in taghandlers.php, can’t see an attribute for that tag. (Doesn’t mean it’s not there! Not an expert.)

Offline

#7 2008-04-23 01:56:26

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: RSS feeds and ampersands in titles

I think I was wrong: no_widow="0" <- there is a widow, so there isn’t a &#160;

Sorry.
Try that one.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#8 2008-04-23 01:58:00

moslib
Member
Registered: 2005-08-11
Posts: 39

Re: RSS feeds and ampersands in titles

Ah yes – thank you! Too easy.

Offline

#9 2008-04-23 06:54:15

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

Re: RSS feeds and ampersands in titles

Yes, my fix targets the built in RSS feed.

Offline

Board footer

Powered by FluxBB