Show past events in module or menu

More
13 years 6 months ago #4713 by pmkdk
Show past events in module or menu was created by pmkdk
Hello

The module only shows FUTURE events.

Is it possible to list past events also?

Thanks

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago - 13 years 6 months ago #4732 by pmkdk
Replied by pmkdk on topic Re: Show past events in module or menu
Thanks to the great coding in the module, it was actually easy for us to spot what to do , in order to show past events aswell.

Following is the code from mod_eb_events.php from the module folder.

Please notice that this module has additional features, such as showing events based on specified categories.

If y ou want to edit your standard module to show past events, then spot the changes in the "event_date" part, in order to do the changes.
Code:
<?php defined('_JEXEC') or die ('Restricted access'); require_once JPATH_ROOT.DS.'components'.DS.'com_eventbooking'.DS.'helper'.DS.'helper.php'; $db = & JFactory::getDBO(); $numberEvents = $params->get('number_events', 6); $categoryId = $params->get('category_id', ''); $where = array() ; $where[] = ' a.published = 1 '; $where[] = ' event_date < NOW() ' ; //very important line $where[] = '(cut_off_date = "'.$db->getNullDate().'" OR cut_off_date >= NOW())' ; if ($categoryId) { $where[] = ' a.id IN (SELECT event_id FROM #__eb_category_events WHERE category_id IN('.$categoryId.'))' ; } $where = implode(' AND ', $where) ; $sql = 'SELECT a.id, a.title, a.event_date, a.category_id FROM #__eb_events AS a WHERE '.$where.' ORDER BY event_date DESC LIMIT '.$numberEvents; $db->setQuery($sql) ; $rows = $db->loadObjectList(); for ($i = 0 , $n = count($rows) ; $i < $n; $i++) { $row = $rows[$i] ; //Get the first category id and name which this event assigned to $sql = 'SELECT a.name FROM #__eb_categories AS a INNER JOIN #__eb_category_events AS b ON a.id = b.category_id WHERE b.event_id='.$row->id.' LIMIT 1 '; $db->setQuery($sql) ; $rowCategory = $db->loadObject(); if ($rowCategory) { $row->category_name = $rowCategory->name ; } } $config = EventBookingHelper::getConfig() ; $document = & JFactory::getDocument() ; $css = JURI::base().'modules/mod_eb_p_events/css/style.css' ; $document->addStyleSheet($css); $itemId = EventBookingHelper::getItemid() ; require(JModuleHelper::getLayoutPath('mod_eb_p_events', 'default')); ?>
Last edit: 13 years 6 months ago by pmkdk.

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc