Other

Writting a plug-in

To write a module plug-in for RSSFit, you can refer to the RSSFit plug-in sample available in our download area.

You can follow the instructions commented in the plug-in sample and modify the code to match you needs. This job usually takes no more than 15 minutes if you are handy with your targeted module.

Although coding a plug-in for RSSFit is not so difficult, we do not encourage you to do it without a basic understanding of programming in PHP.

This file below is a dummy for making a RSSFit plug-in, follow the following steps if you really want to do so:

  • Step 0: Stop here if you are not sure what you are doing, it's no fun at all

  • Step 1: Clone this file and rename as something like rssfit.[mod_dir].php

  • Step 2: Replace the text "RssfitSample" with "Rssfit[mod_dir]" at line 59 and line 65, i.e. "RssfitNews" for the module "News"

  • Step 3: Modify the word in line 60 from 'sample' to [mod_dir]

  • Step 4: Modify the function "grabEntries" to satisfy your needs

  • Step 5: Move your new plug-in file to the RSSFit plugins folder, i.e. your-xoops-root/modules/rssfit/plugins

  • Step 6: Install your plug-in by pointing your browser to your-xoops-url/modules/rssfit/admin/?do=plugins

  • Step 7: Finally, tell us about yourself and this file by modifying the "About this RSSFit plug-in" section which is located... somewhere.

[mod_dir]: Name of the driectory of your module, i.e. 'news'

Below is the sample code:

<?php

if (!defined('RSSFIT_ROOT_PATH')) {
    exit();
}

/**
 * Class RssfitSample
 */
class RssfitSample
{
    public $dirname = 'sample';
    public $modname;
    public $grab;
    public $module;    // optional, see line 71

    /**
     * @return bool
     */
    public function loadModule()
    {
        $mod = $GLOBALS['module_handler']->getByDirname($this->dirname);
        if (!$mod || !$mod->getVar('isactive')) {
            return false;
        }
        $this->modname = $mod->getVar('name');
        $this->module  = $mod;    // optional, remove this line if there is nothing
        // to do with module info when grabbing entries
        return $mod;
    }

    /**
     * @param $obj
     * @return bool
     */
    public function &grabEntries(&$obj)
    {
        global $xoopsDB;
        $myts = \MyTextSanitizer::getInstance();
        $ret  = false;
        $i    = 0;
        //    The following example code grabs the latest entries from the module MyLinks
        $sql    = 'SELECT l.lid, l.cid, l.title, l.date, t.description FROM ' . $xoopsDB->prefix('mylinks_links') . ' l, ' . $xoopsDB->prefix('mylinks_text') . ' t WHERE l.status > 0 AND l.lid = t.lid ORDER BY date DESC';
        $result = $xoopsDB->query($sql, $this->grab, 0);
        while ($row = $xoopsDB->fetchArray($result)) {
            $link = XOOPS_URL . '/modules/' . $this->dirname . '/singlelink.php?cid=' . $row['cid'] . '&amp;lid=' . $row['lid'];
            /*
            * Required elements of an RSS item
            */
            //    1. Title of an item
            $ret[$i]['title'] = $row['title'];
            //    2. URL of an item
            $ret[$i]['link'] = $link;
            //    3. Item modification date, must be in Unix time format
            $ret[$i]['timestamp'] = $row['date'];
            //    4. The item synopsis, or description, whatever
            $ret[$i]['description'] = $myts->displayTarea($row['description']);
            /*
            * Optional elements of an RSS item
            */
            //    5. The item synopsis, or description, whatever
            $ret[$i]['guid'] = $link;
            //    6. A string + domain that identifies a categorization taxonomy
            $ret[$i]['category'] = $this->modname;
            $ret[$i]['domain']   = XOOPS_URL . '/modules/' . $this->dirname . '/';
            //    7. extra tags examples
            $ret[$i]['extras'] = [];
            //    7a. without attribute
            $ret[$i]['extras']['author'] = ['content' => 'aabbc@c.com'];
            //    7b. with attributes
            $ret[$i]['extras']['enclosure']['attributes'] = ['url' => 'url-to-any-file', 'length' => 1024000, 'type' => 'audio/mpeg'];
            $i++;
        }
        return $ret;
    }
}

When RSSFit met Podcast

Since version 1.2, RSSFit has the ability to output extra tags generated by different plug-ins. With the release of it's 1.21 version, it also has released a modified WF-Download 3.1 plug-in for the use of simple podcasting. This article may help you a bit if you want to know more about the concept behind it.

1. So what on earth is podcasting? From Wikipedia: Podcasting is the method of distributing multimedia files, such as audio programs or music videos, over the Internet using either the RSS or Atom syndication formats, for playback on mobile devices and personal computers.

2. Why do you call this a "simple podcast" solution? Unlike iTunes or FeedBurner that provide their exclusive methods for publishing podcast feeds, the format of the RSS output generated by RSSFit follows the specification published through Harvard Law School. The only difference between a general feed and a podcast feed is the "enclosure" tag that contains information about your media files.

3. Okay I don't care. What do I need to do podcasting my media files from my XOOPS site without learning a single line of code? XOOPS 2.0.14 RSSFit 1.21 WF-Downloads 3.1

4. Why WF-Downloads 3.1? WF-Downloads 3.1 is the first, and so far the only module we found that provides information (file url, size and MIME type) needed for the "enclosure" tag of a podcast feed.

5. I want my visitors to log in before downloading my files. Can I keep such restriction on podcasting? Only if you can use a podcast reader software to log in like what you usually do with a browser.

6. Why not module X or Y, maybe Z? We don't have enough time to do it.

7. Is it possible to create iTunes podcast feeds using RSSFit? If so, how? Yes it is. However, publishing a tutorial for doing so is currently not in our schedule.

Externals

RSS 2.0 Specification Introduction to the RSS technology and a list of RSS elements with descriptions and examples.

XML Transformations with CSS and DOM Explains how to make modern browsers render your XML documents with a better look by adopting CSS and DOM.

FEED Validator Validates your RSS and Atom feeds.

Last updated