How to add an RSS feed icon to your e107 news items

[b]RSS (Really Simple Syndication)[/b] is a tool that enables you to syndicate your content and deliver it straight to your subscribers, saving them time and keeping them up to date with new content.

The core e107 RSS menu makes it easy to set up your own feed but I didn't like the menu format. For this site I wanted an RSS icon on each news item, similar to the news posts on [link=http://www.e107.org]e107.org[/link]. It is not an option in the core preferences but it is very easy to implement without any core code changes. I'm going to try and show you how it's done.

{GOOGLEADS}
Once you have successfully installed the RSS menu and have a valid feed you are ready to go.

Firsly, make a note of the feed url – it will look something like this:

[code]YOURSITE/e107_plugins/rss_menu/rss.php?1.2[/code]

[img]{e_IMAGE}rss_newspost.png[/img]

Next you want an RSS icon. There are [link=http://www.hongkiat.com/blog/free-rss-feed-icons-the-ultimate-list/]hundreds of them around[/link], just find one that you like and resize if necessary, 14px x 14px is good and save as [b]rss_icon.png[/b]. Using FTP, upload to your theme images folder.

Now open your favourite [link=http://notepad-plus.sourceforge.net/uk/site.htm]text-editor[/link] and type the following code. You will need to replace my rss feed url with the rss feed address you made a note of earlier. Also, double check that the image target is correct and pointing to the RSS icon you made earlier.

[code]
global $tp;
$ret = "

images/rss_icon.png' alt=''/>

";
return $ret;
[/code]

Save the file as rssicon.sc. This is the [link=http://wiki.e107.org/?title=Category:Shortcodes]shortcode[/link] that displays the RSS icon on your site. Upload the rssicon.sc to you theme folder.

You may notice that we use [link=http://www.feedburner.com/fb/a/home]Feedburner[/link] to syndicate our RSS feeds. Feedburner gives you more control over how users subscribe to your content and enables you to analyze your feed traffic. Its just as easy to set up, just open an account and validate your feed.

Open your themes [b]theme.php[/b] and add the following somewhere near the top. After the theme info is a good place, just make sure it is above the [b]$HEADER[/b] :

[code]$register_sc[]='RSSICON';[/code]

This makes sure that the [link=http://wiki.e107.org/?title=Shortcodes:Themes]shortcode will be recognised by the theme[/link] without having to edit any core files.

We are almost there now. We have made the icon and shortcode and uploaded them and we have registered the shortcode with our theme. Now we need to edit our [link=http://wiki.e107.org/?title=Creating_a_theme_from_scratch#News_Render_Style]news display[/link] so the icon is visible. Still in theme.php took for [b]$NEWSSTYLE[/b], it will be nearer the bottom usually. In the news style layout place the [b]{RSSICON}[/b] where you want it to be displayed. A good place is next to the {EMAILICON } or {PRINTICON }

Ands that's it! Easy! The great thing about this technique is that it doesn't affect any core files and won't be altered during an upgrade. You can also place the {RSSICON} shortcode anywhere you like, so be imaginative.

6 thoughts on “How to add an RSS feed icon to your e107 news items

  1. jezza101

    Nice Idea, I like the in post adsense you have here too. I guess you've just put it into the news template?

    I might have a go at this, getting subscribers is a nice way to keep your site in people's minds!

  2. Was actually easier than that. Used a {GOOGLEADS} shortcode and just place the shortcode at the top of the extended news in admin. :)

  3. I would like to add

    For $ register_sc[]="RSSICON";
    Recommendation to place near the top under <?php
    I had placed above the $HEADER and didnt work.

    Also, it is not $ register_sc[]="RSSICON";
    It is really
    $register_sc[]='RSSICON';
    No space between the $ and register.
    Also no ", instead '.

    I am not a coder, but once I used the above it worked.
    GREAT post btw.

  4. Thanks for correcting that. Although the " or ' is dependant on your theme, the space between the $ and register shouldn't be there.

    I have ammended the post to include these changes.

    Thanks again DOA

Comments are closed.