Fixing RSS with MT2.6
Update: Phil Ringnalda posted a plugin that takes care of encoding CDATA tags (and some other stuff) to prevent accidental RSS feed breakage.
Update 2: Tim Appnel wrote 2 plugins to fix my issues too. The first one is mt-entrybodymore which allows you to use <MTEntryBodyMore> to display the full entry instead of using <MTEntryBody> and <MTEntryMore>. He also wrote mt-xmlencode-block which I'm using to wrap my comments feed.
I'd like to thank Phil, Ben and Tim for all of their help. My site feeds both validate as does my comments feed (I cleaned it up a little).
The first problem: There's a bug in MT2.6 (which should be fixed soon, but I can help you if you need to fix it ASAP) that causes encode_xml to be called before Sanitize. That means that all of your nicely encoded content gets a lot of tags removed from it, which makes a mess. There's an easy fix for this (see below).
Second problem: The next problem is because I have a full content RSS feed (and also a comment RSS feed). To generate the full content RSS feed, I have the following in my RSS file:
<description><$MTEntryBody encode_xml="1" resolve_urls="1"$><$MTEntryMore encode_xml="1" resolve_urls="1"$></description>
The problem is that I have 2 tags (MTEntryBody and MTEntryMore) that have encode_xml="1". Because of that, each section is wrapped with CDATA tags. This causes a problem with some newsreaders because they aren't expecting 2 CDATA tags within the description, so they'll only display the second CDATA in the reader. Unless you're using Radio and then you only get the headings. [See Brad's weblog for more info.]
To fix this, you have to put your own CDATA tags in and remove the encode_xml tags like this:
<description><![CDATA[<$MTEntryBody resolve_urls="1"$><$MTEntryMore resolve_urls="1"$>]]></description>
Fix #1 from Phil Ringnalda (taken from the MT forum):
"for a quick fix you need to edit {your MT directory}/lib/MT/Template/Context.pm, find sub post_process_handler, and move (this code is around line 240):
if ($local_args{'encode_xml'}) {
$str = encode_xml($str);
}
down below:
if (my $spec = $local_args{'sanitize'}) {
require MT::Sanitize;
if ($spec eq '1') {
$spec = $ctx->stash('blog')->sanitize_spec ||
MT::ConfigMgr->instance->GlobalSanitizeSpec;
}
$str = MT::Sanitize->sanitize($str, $spec);
}
so that sanitize runs first, and doesn't eat the opening CDATA tag that encode_xml sticks in."
7 Comments
6 TrackBacks
Listed below are links to blogs that reference this entry: Fixing RSS with MT2.6.
TrackBack URL for this entry: http://www.beantowngeek.com/cgi-bin/mt/mt-pong.cgi/144
A MovableType plugin that output both the entry body and "more" fields with one tag because you may find a need for it. Read More
Lisa needed something like this for her full-text RSS feed. Read More
Finally got around to doing what I promised ages ago. It was simple, just copy the .pl plugin that Unix-Gal... Read More
Finally got around to doing what I promised ages ago. It was simple, just copy the .pl plugin that Unix-Gal... Read More





Hmm, that's really weird. I'm sorry we didn't catch it BEFORE everybody got to download
(flips my hair like a girl who doesn't know a thing!!! )
I wonder why Sanitize is being called where it would affect the EntryBody and EntryMore tags. Since its just for comments, that seems odd. Ahh, well, as long as it gets fixed, I should stop trying to stare at Perl code when I know almost nothing
The EntryBody and EntryMore problem is that it creates a CDATA for each which makes newsreaders grumpy. Sanitize was the first problem only.
Broken index RSS for your viewing pleasure.
One more thing you might want to add to your comment feed fixup, if not your main feed, just so people don't put ]]... oh, that would be cruel.
All fixed up! Thanks, Phil.
Testing... ]]>
Sorry, I was gonna email you after I got done adding those, but I went and took a nap first instead.
and I did take a
with me and actually got some reading done with my little conversation hearts for entertainment too . LOL, I'm silly!
I followed your first tutorial to make my RSS feeds. I validated at that time.
Then I noticed I wasn't validating sometimes. I'm not sure what the pattern is for when I DO and DON'T validate, it just happens on SOME entries, while not for others.
So after researching, I find this page, and Phil's page, and after doing numerous things to my xml template, I'm still not validating.
Here's what I've done:
1. I changed my description code to this:
<description><![CDATA[]]></description>
2. When I still wouldn't validate, I uploaded Phil's SmartestXMLEncode.pm to my plugins directory (in ascii and CHMOD 755), then added this to the description code:
<description><![CDATA[]]></description>
3. When that wouldn't validate, I looked in my context.pm, and the sanitize code was already above the code:
if ($local_args{'encode_xml'}) {
$str = encode_xml($str);
}
Sherri
Nothing in Particular | XML