MyBlog RSS Trouble
Posted on , 2009 by james2 in joomla , components
If you're interested in hiring me for a project, Contact me for more info.
Posted on , 2009 by james2 in joomla , components
On one of the sites I work on, Azrul's MyBlog component is utilized for the site's blogging. Recently, one of the users informed me of the fact that the feed wasn't working. Upon closer inspection using a feed validator, I realized that what was being spit out in the feed was nowhere near what should be in an RSS feed. Instead, the feed URL seemed to be spitting out an XHTML valid web page.
After some digging in the MyBlog forums, I came across a few users who suggested that it might be other junk in the URL causing the problem. Taking a look at the current URL, it looked something like this:
http://example.com/index.php?option=com_myblog&Itemid=120&task=rss
Nothing specifically suspicious about this. Just for kicks though, I tried removing the "&Itemid=120"bit from the URL. Low and behold, it suddenly validated.
Now that I knew what the correct URL was, I had to change the URL that was in the MyBlog toolbar and the RSS URL that was picked up by the browser. To do that I had to dig into two files.
First up, the 'Feed' link in the MyBlog toolbar. To change this, I first found this file:
/components/com_myblog/templates/_default/toolbar.tmpl.html
On line 18, look for the following piece of code:
<.li class="toolbarFeed"><.a href="<.?php echo $toolbar['rssFeedLink']; ?>">_MB_FEED<./a><./li>
...and replace it with this (without the '.' in the opening and closing tags):
<.li class="toolbarFeed"><.a href="http://example.com/index.php?option=com_myblog&task=rss">_MB_FEED<./a><./li>
That essentially hard-codes the correct URL into the link. The next task is to change the link that MyBlog spits out for browsers to pick up on. To do that, I tracked down this file:
/components/com_myblog/task/base.php
On lines 160 and 161, you'll see the 'if' part of the RSS URL function that deals with the 'Itemid'. This may be useful to some, but it wasn't to me, so those two lines got completely commented out. What I found out that doing this will do is that it will add the "&Itemid=xx" to the end of the RSS URL, which apparently still works for feed validators and RSS readers.
As you can see, both fixes are hacks to the core of the MyBlog component. Hack at your own risk, and don't forget to back these files up when you update the component in the future.