RSS feed, adding to a plugin

From e107 Wiki
Jump to: navigation, search

e107 Wiki: English | Русский | Deutsch | Français | Magyar | Português | Български | Česky | Nederlands | Ελληνικά | Italiano | Norske | Polska | Slovenščina | Español | Svenska | Translate: Wiki | Page

logo_wiki.png

Current Release 1.0.4 | e107.org | Download | Changelog | Forum | Plugins | Themes | RSS Feed of Latest Changes | Atom Feed of Latest Changes


How to write a plugin
Main page > I : First Aid > II : Development > III : Administration > IV : How To's > V : Plugin Writing > VI : Theming & Shortcodes


Adding RSS Feeds To A Plugin

As of e107 0.7 you can have RSS feeds generated for your particular plugin automatically. To add this functionality to your plugin, you need to create an e_rss.php file in the root of your plugin folder.

Each e_rss.php file consists of two main parts. The first part creates an array called $eplug_rss_feed[]. This array is used to 'locate' the rss feeds for the rss admin area import feature. This array consists of the following values:

Code: e_rss.php snippet
// ##### e_rss.php ---------------------------------------------
$feed['name']     = 'Chatbox';
$feed['url']      = 'chatbox';
$feed['topic_id'] = '';
$feed['path']     = 'chatbox_menu';
$feed['text']     = 'rss feed for the chatbox entries';
$feed['class']    = '0';
$feed['limit']    = '9';
//##### --------------------------------------------------------
  • name
    caption for display (used in rss.php rss feed list page)
  • url
    identifier for the rss feed url (rss.php?A.B.C -> A) (does not need to be numeric)
  • topic_id
    topic_id, empty on default (to select a certain category) (rss.php?A.B.C -> C), use '*' for dynamically read topic_id)
  • path
    plugin path location (use path|parm for multiple switches, see forum)
  • text
    description for the rss.php feed list page
  • class
    0=active and visible in rss feed list, 1=active and not visible in rss feed list, 2=inactive (default=0)
  • limit
    number of items to show in the rss feed

The second part creates an array called $eplug_rss_data[]. This array is used to 'retrieve' the rss feeds records for the rss generator. This array consists of the following values:

Code: e_rss.php snippet
//##### create rss data, return as array $eplug_rss_data -------
$rss = array();
if($items = $sql -> db_Select('chatbox', "*", "cb_blocked=0 
ORDER BY cb_datestamp DESC 
LIMIT 0,".$this -> limit)){

  $i=0;
  while($rowrss = $sql -> db_Fetch()){
    $tmp = explode(".", $rowrss['cb_nick']);
    $rss[$i]['author']        = $tmp[1];
    $rss[$i]['author_email']  = '';
    $rss[$i]['link']          = $e107->base_path.$PLUGINS_DIRECTORY."chatbox_menu/
                                chat.php?".$rowrss['cb_id'];
    $rss[$i]['linkid']        = $rowrss['cb_id'];
    $rss[$i]['title']         = '';
    $rss[$i]['description']   = $rowrss['cb_message'];
    $rss[$i]['category_name'] = '';
    $rss[$i]['category_link'] = '';
    $rss[$i]['datestamp']     = $rowrss['cb_datestamp'];
    $rss[$i]['enc_url']       = "";
    $rss[$i]['enc_leng']      = "";
    $rss[$i]['enc_type']      = "";
    $i++;
  }
}
//##### --------------------------------------------------------

Required elements:

  • author
    holds the name of the author of the retrieved item.
  • author_email
    holds the email address of the author of the retrieved item.
  • link
    the full url that is specific to the particular item.
  • linkid
    the identifying id value for retrieved item.
  • title
    field name where the title is located.
  • description
    a description for the retrieved item, could be a subheading, summery or posted text.
  • category_name
    the name of the category.
  • category_link
    the full url to the category page.
  • datestamp
    the date when the item was added.

Optional elements - particularly useful for Podcasting.

  • enc_url
    URL to related media. eg. mp3 file.
  • enc_leng
    size of the media in bytes.
  • enc_type
    path to the file (automatically converted to mime type. )