Here I will discuss modifying a module using the mod_feed module as a starting point. We will change the feed module to allow sorting by date. So here goes.

Make a copy of the /modules/mod_feed directory (including the contents) and rename the folder to mod_feed_order (since we will be focusing on allowing ordering of the feeds by date). Do the same thing with the /administrator/modules/mod_feed directory as well.

Next rename the mod_feed.php file within both of your new module directories to mod_feed_order.php and the mod_feed.xml to mod_feed_order.xml

Copy the /language/en-GB/en-GB.mod_feed.ini and rename it /language/en-GB/en-GB.mod_feed_order.ini
then add the following entry at the end of the file
PARAMDATEORDER=Changes the date ordering of the feeds.

 

Now we make some file changes

/modules/mod_feed_order/mod_feed_order.php
Change the following lines from:
$feed = modFeedHelper::getFeed($params);
require(JModuleHelper::getLayoutPath('mod_feed'));
to
$feed = modFeedOrderHelper::getFeed($params);
require(JModuleHelper::getLayoutPath('mod_feed_order'));

/administrator/modules/mod_feed_order/mod_feed_order.php
Change the following lines from:
require(JModuleHelper::getLayoutPath('mod_feed'));
to
require(JModuleHelper::getLayoutPath('mod_feed_order'));

/modules/mod_feed_order/helper.php
Change the following lines:
class modFeedHelper
to
class modFeedOrderHelper
and right after the line
$rssDoc =& JFactory::getXMLparser('RSS', $options);
add the lines
// wpg - enable ordering by date and order based on the date order parameter
$rssdateorder = $params->get('rssdateorder', '');
if ($rssdateorder != 2) {
$rssDoc->enable_order_by_date();
$rssDoc->order_by_date = $rssdateorder;
}

/modules/mod_feed_order/mod_feed_order.xml and /administrator/modules/mod_feed_order/mod_feed_order.xml
Change the files element from:
<files>
<filename module="mod_feed">mod_feed.php</filename>
</files>
to
<files>
<filename module="mod_feed_order">mod_feed_order.php</filename>
</files>

Then change the name element from
<name>Feed Display</name>
to (this will be used by the administrative view when adding a new module)
<name>Feed Display With Ordering</name>

then after the line
<param name="word_count" type="text" size="6" default="0" label="Word Count" description="PARAMWORDCOUNT" />
add the lines (which will setup our date ordering parameter; you can default it to whatever you want but I have it defaulting to ‘no date ordering’)
<param name="rssdateorder" type="radio" default="2" label="Date Order" description="PARAMDATEORDER">
<option value="1">Descending</option>
<option value="0">Ascending</option>
<option value="2">No Date Ordering</option>
</param>
also you may want to change the description element to
<description>This module allows the displaying of a syndicated feed. It was modified by wpg - March 2008 to include a sorting by date option.</description>

/administrator/modules/mod_feed_order/tmpl/default.php
Change the line
<?php echo modFeedHelper::render($params); ?>
to
<?php echo modFeedOrderHelper::render($params); ?>

Now we should be all set to add the module to our site!
So you followed all of the directions above right? You should now have the module all set and ready to go. If you log into the Joomla administrator now and go to the Module Manager under Extensions, then select the New module button, and you should see a list of all of your modules. The new module you just added, Feed Display with Ordering, should now appear in the list. Click this option and you should now see our original feeds module with an additional parameter for specifying the Date Order.

Congrats, you just added a new module to Joomla!