From MoodleDocs
Revision as of 07:45, 16 January 2012 by Jason Fowler (talk | contribs)


The RSS API is a core system in Moodle to allow you to create secure RSS feeds of data in your module.

These RSS feeds can then be syndicated by other websites or aggregated by a feed reader.

Any Moodle module can generate RSS feeds to allow secure access to it's data.

File Locations

The primary functions for the RSS API is located in lib/rsslib.php

Additional functions and usage examples can be found in the following files:

  • blog/rsslib.php
  • mod/data/rsslib.php
  • mod/forum/rsslib.php
  • mod/glossary/rsslib.php


Below you will find examples on how to use the RSS functions within your own modules.

Creating an RSS feed


Caching an RSS feed


Retrieving a cached RSS feed


Linking to a RSS feed

This example shows how you can output a link to an RSS feed. (Example taken from blocks/news_items/block_news_items.php)

$cm = $modinfo->instances['forum'][$forum->id];
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$forum = forum_get_course_forum($this->page->course->id, 'news');
$userid = (!isloggedin()) ? 0 : $USER->id;
$tooltiptext = get_string('rsssubscriberssposts','forum');
echo rss_get_link($context->id, $userid, 'mod_forum', $forum->id, $tooltiptext);

See also