Reputation: 5379
How do I create a module that would display the number of articles in one category that have been published each month. Something similar to WordPress, eg.
December 2016 (3)
November 2016 (5)
etc.
Thanks
Upvotes: 0
Views: 100
Reputation: 1272
You should follow joomla tutorial to create a new module, that's quite simple : https://docs.joomla.org/J3.x:Creating_a_simple_module/Developing_a_Basic_Module/en
Once you have created the hellow world module as described in tutorial, you should modify the file helper.php and create a new function :
public static function getPublicationsByMonth(){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('DATE_FORMAT(created, "%M %Y") as date, count(*)')
->from('#__content')
->where('state = 1')
->group('date');
$db->setQuery($query);
return $db->loadObjectList();
}
Then in tpl/default.php you should use result of this method to display results as you want.
Upvotes: 1