Working around the broken RSS feed code in Joomla! 3.2
I'll probaby backfill some more tips & tricks I've picked up this past week, during an upgrade of a client's site from Joomla! 1.5.22 to 3.2, but in the meantime, as this seems to be a nagging bug (well a collection of them; not necessarily a swarm or even a hive, but a colony, nonetheless), I figured I should get something posted about it to hopefully save someone else an hour or two of poking (and testing modules to just replace the built-in feed module, anyway).
No Hyperlinks
If you're reading this in earnest, you probably have some idea of how Joomla! works. That basic flow of logic remains unchanged through the current 3.2 release. (Aside: I surely wish that the Joomla! folks would get their collective act together and deal with version updates and upgrades the way WordPress handles them. Moving from 1.5 to 3.2 is essentially a matter of rebuilding the entire site. If lucky, the articles can be dumped from the existing db and imported into the new one - there are a couple good extensions for that - but after the raw content, it's just like starting from scratch.)
One of the things I noticed a couple of nights ago, when I finally turned on the web feeds for this site, was that one of them wasn't displaying hyperlinks. That is to say, the content of the feed was visible both in the sidebar and in an article display, but it was impossible to click through to read the balance of the entry; it was all just plain text. This only impacted one feed, however; the second feed looked perfectly normal with clickable links.
I'll get into some of the nuts and bolts of the differences between the two feeds later. For now, however, suffice it to say that I went looking for an answer, once I checked the feed url in a browser and found all of the entries to be clickable there.
The Joomla! forum provided my first clue not only as to how to go about working around the problem, but also that I was not alone (either with a broken site or with some sort of munged feed). Per the forum entry linked above, the key to the workaround is to override the default <joomla root>/modules/mod_feed/templ/default.php with the fixed code in <joomla root>/templates/<template name>/html/mod_feed/default.php, changing:
$uri = (!empty($feed[$i]->guid) || !is_null($feed[$i]->guid)) ? $feed[$i]->guid : $feed[$i]->uri;
(near line 90, in the mod_feed default.php from Joomla! 3.2) to:
$uri = (!empty($feed[$i]->uri) || !is_null($feed[$i]->uri)) ? $feed[$i]->uri : $feed[$i]->guid;
This gets the hyperlinks working. However, the downside is that due to a couple of missing HTML tags, this will likely break your site (don't worry; it's not that broken!)...
Missing tags:
First, there is a missing </ul>
tag around line 79. This prevents bullets from appearing next to each item in the RSS feed, and this buglet impacts the non-modified default.php. This is an easy fix, though: add the closing tag (</ul>
) on the line following:
<ul class="newsfeed<?php echo $params->get('moduleclass_sfx'); ?>">
Next, the thing which breaks the site (but oddly, not unless overriding the default mod_feed file) is a missing </div>
tag around the next to last line of the file. Without adding this tag, enabling the feed in a sidebar will never close the division, and thus, the content and everything else will appear in a nice, narrow column, right underneath your feed block.
Once these two HTML issues are fixed, your feeds should look as good as they work.
There is an open bug in the JoomlaCode tracker for the HTML tags. I haven't found one for the broken links, however.
What's different between the working and non-working feeds?
What seems to be working are genuine, well-formed, RSS 2.0 feeds. Here's an excerpt (urls obfuscated) of a working feed with a .rss extension on the file:
<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule" > <channel> <title>Feed title</title> <link>http://www.somedomain.tld</link> <description>A brief description of the feed content.</description> <language>en</language> <lastBuildDate>Wed, 20 Nov 2013 11:20:35 EST</lastBuildDate> <docs>http://backend.userland.com/rss-2-0</docs> <managingEditor>rss_editor@somedomain.tld</managingEditor> <webMaster>webmaster@somedomain.tld</webMaster> <image> <title>Some Feed Provider</title> <url>http://www.somedomain.tld/images/picture.gif</url> <link>http://www.somedomain.tld/feed-dir</link> <width>52</width> <height>31</height> <description>A briedf description of the image file.</description> </image> <item> [...] </item> <item> [...] </item>
What doesn't seem to work without the correction to the placement of the guid and url params (above) is an rss file akin to this (note the absence of the opening tags; this ):
<?xml version="1.0" encoding="utf-8"?> <rss version="2.0"> <channel> <title>Feed Title</title> <link>http://www.somedomain.tld/feed</link> <description>Descriptive text.</description> <pubDate>Thu, 21 Nov 2013 09:02:05 -0500</pubDate> <lastBuildDate>Thu, 21 Nov 2013 09:02:05 -0500</lastBuildDate> <item> <title>News Item Title</title> <link>http://www.somedomain.tld/article.html</link> <guid isPermaLink="false">d27449db-72de-4b91-b7e1-997e4b18adc7</guid> <description>News content to display for this article.</description> <pubDate>Thu, 21 Nov 2013 09:02:05 -0500</pubDate> </item> </channel> </rss>
The above feed should be entirely legitimate. It includes GUIDs, however, where the previous one did not. Apparently, the inclusion/placement of the GUIDs causes some confusion for the unmodified code.
Helpful links:
GavickPro forum (discussion of open div tag)
Joomla! forum (discussion of default.php and open ul tag)
Last Updated on by
November 26th, 2013 - 13:34
Since posting this, I submitted a patch to JoomlaCode (though in my own patch, I duped a <ul> tag, myself…oops!). It has been tested (after removing the extra <ul> tag), and hopefully will make it into the next update. The Joomla! folks have been quite responsive, especially considering the number of issues in the bug tracker.