Adding RSS icons to a joomla template

We’re using Joomla on Vquence’s corporate site and wanted to display RSS icons and provide proper feeds for the blogs and news posted there.

The new Joomla 1.5 provides the ability to add to every Menu item that is a Blog List an RSS feed by introducing an rss and atom link tag in the html head tag. However, we wanted to have the RSS icon for subscriptions displayed on the page, too, and that turned out to be not so simple.

Here is the piece of code that we eventually added to our body tag:

<div id="rss" style="float: right;" >
<?php $headData = $this->getHeadData() ?>
<?php if(count($headData['links']) != 0) : ?>
<a href="<?php echo JRoute::_('index.php?format=feed&type=atom', false) ?>"><img src="/images/rss.gif" alt="rss icon"/></a>
<?php endif; ?>
</div>

Fortunately, this also worked for the aggregated planet blog feed we are displaying in Joomla as an article under Team Blog and for which we had to install the CustomHeadTag plugin to add the link tags to the html page head.

Counting the number of links in the Joomla HeadData seemed to be the best way to find out whether or not to add the RSS feed icon. This is in no way or shape optimal or the best solution, but we were unable to find a way to get directly to the parameters of the menu items and query that show_feed_link parameter of the menu item. Online documentation for this type of template work is non-existent as yet.

If anyone has a better solution, leave a comment!

4 thoughts on “Adding RSS icons to a joomla template

  1. If I understand correctly what you are trying to do, I think there is an easier way. In admin, If you go under “Module Manager”, create a new one, choose “syndicate” then click “next”. Fill in a title (don’t show title though), enable it, choose what module position (ex. footer, or whatever), and what menu pages you want the feed icon to show up on. Under “parameters” it should be set to “never” under caching, and choose “rss 2.0″ for format. For the”text” put in whatever you want (ex. RSS feeds). The only problem is that on the front of the site, it will show the text along with the icon. Now if I could just figure out how to get rid of the text…

  2. karen, underclass: thanks for the tip. It looks like that should work in a much more joomla-conformant way. It didn’t work for me when I briefly gave it a shot, but that may have something to do with my custom template. I’ll leave it for now, but keep your idea on mind for a future update. Thanks!

Comments are closed.