RSS Library

  • Use this library to create RSS feeds in your modules.
  • You should use xml streaming library in order to stream the created RSS Feed to the user.
  • Include the following function in the script to load the library.

Starting a RSS Feed


Open a RSS channel

  • Use shn_rss_channel_open() function to open a channel.
  • Parameters as follow
    1. $title : Title of the RSS Feed.
    2. $desc : A Description about the RSS Feed.

Add an Item to Channel

  • Use shn_rss_item() to add an item to a channel
  • You can add any number of items to a single channel.
  • Parameters as follow
    1. $title : Title of the item
    2. $link : Link where the Item should point to
    3. $description : Description of the Item
    4. $extra_opt : If you have other tags which should come under item parse them as an array with tag name and the value as pares array('tag_name'⇒'value').

Close a Channel

Close a RSS Feed

Adding a Feed icon to a module page

  • Use shn_rss_add_feed() to add a RSS Feed icon and a link to a web page.
  • Parameters as follow
  1. $act : action
  2. $title : Title of the Feed
  3. $desc : This is an optional field where you give a description of a feed.
  • When you add a Feed link it will look as follows.

Example of Usage

Following is a code segment used to create a RSS Feed that notify Expired items in the inventory management system.

function shn_xml_ims_rss_expired_list(){
    global $global;
    _shn_ims_expire_date_check(); // ignore this function
    shn_rss_channel_open(_('Expired item List'),_('Following are a list of items which have been expired recently in SAHANA inventory.'));
    $sql="SELECT item_id,inv_id,item_name,amount, as unit,manufactured_date,expire_date FROM ims_item_records as i INNER JOIN ct_unit ON ct_unit.unit_uuid = i.unit WHERE state='expired' ORDER BY expire_date LIMIT 0, 30;";
    $res = $global['db']->Execute($sql);
    if (!$res){add_error($global['db']->ErrorMsg());}
    //remember the link used in items should be a full uri in order for the readers to access it.
    foreach($res as $record){
        $desc=_("This item is manufactured on ").$record['manufactured_date']._(" and expired on ").$record['expire_date']."."._(" And Currently there are ").$record['amount']." ".$record['unit']._(" left in the inventory.");

To add a link to the above feed the following function has been used.

    shn_rss_add_feed('rss_expired_list',_('Expired item List'),"A list of expired items in the inventories.");

QR Code
QR Code swat:rss_library (generated for current page)