Forum
RSS not showing content, but it is in the code
A bit confused here. I've got the basics of my RSS feed setup - the rss.php file, the rss_post.html template. When I view the feed in Firefox, I see only the hard-coded title and subtitle. Not the posts. But when I view the code, I see everything I should....the post titles, descriptions, etc.
I moved on and tried connecting this RSS feed to MailChimp - but when I enter the URL that I am seeing the correct code (but not the regular view), MailChimp gives me an error: "Connecting to url failed"
Any ideas what I am missing? Here's my code:
rss.php
<?php
$domain = 'https://'.$_SERVER['HTTP_HOST'];
PerchSystem::set_var('domain', $domain);
header('Content-Type: application/rss+xml');
echo '<'.'?xml version="1.0"?'.'>';
?>
<rss version="2.0" xmlns:atom="https://www.w3.org/2005/Atom">
<channel>
<title>Community RSS Feed</title>
<link><?php echo PerchUtil::html($domain); ?>/dev-community/</link>
<description>Description will be here</description>
<atom:link href="<?php echo PerchUtil::html($domain); ?>/dev-community/rss.php" rel="self" type="application/rss+xml" />
<?php
perch_blog_custom(array(
'template'=>'rss_post.html',
'count'=>100,
'sort'=>'postDateTime',
'sort-order'=>'DESC'
));
?>
</channel>
</rss>
rss_post.html
<item>
<title><perch:blog id="postTitle" /></title>
<link><perch:blog id="domain" /><perch:blog id="postURL" /></link>
<guid><perch:blog id="domain" /><perch:blog id="postURL" /></guid>
<description>
<![CDATA[
<perch:blog id="excerpt" encode="false" /></description>
]]>
<pubDate><perch:blog id="postDateTime" format="D, d M Y H:i:s O" /></pubDate>
</item>
Hi Leigh
I'm wondering if you've told your server to serve up php files as xml?
i.e. Added something like this in your htaccess file?
The only other thing I can think of is if your xml is outputting the urls as http when you are on an https site?
Jon
Thanks for the ideas John. I tried the HTACCESS addition and it made no difference. :( I was hoping that would do the trick - arg. Yes, it's an HTTPS site, with a rewrite from HTTP, so how would I learn if it's outputting incorrectly? Especially when the code looks correct, but not the displaying. Odd.
I just used a feed validator - https://validator.w3.org/feed
And got these results:
So then I did this:
Now it validates! It's showing the proper lines in Firefox, and MailChimp is now accepting the link.
So what happened here? Why did I need to fiddle with this myself to get it right? Why does the Perch documentation show that extra "CDATA" piece and not mention that stripping the HTML tags from the except? Did I just get lucky?
The other thing that I know borks rss feeds is if you've got extra whitespace. Take out any carriage returns that might be at the end of your template(s).
Thanks John - just edited my reply above - got it working, but I'm not totally sure why! No extra spaces - that was the first thing I checked :)
Does the page render if you reduce the xml content to just, say, the title?
Also - is the closing description tag in the wrong position?
Glad to hear it - playing forum tennis it seems!
Indeed! For others who hit this snag, here's my rss_post.html code with the updates I mentioned above: