Fix to show From-To date range in widget
-
Using the Ajax Event Calendar, I needed to show the from-to dates in the widget on the side and could not get a response — so I came up with a solution. It might look ugly, but it was only a few lines to change.
In the ajax-event-calendar.php file, in the following function:
‘function render_eventlist_events($events, $whitelabel, $limit)’
around line 841 called “link to event” here is the original:function render_eventlist_events($events, $whitelabel, $limit) { usort($events, array($this, 'array_compare_order')); $rows = $this->convert_array_to_object($events); $out = ''; foreach ($rows as $count => $row) { //if ($count < $limit) { if (!$limit || $count < $limit) { // split database formatted datetime value into display formatted date and time values $row->start_date = $this->convert_date($row->start, AEC_DB_DATETIME_FORMAT, AEC_WP_DATE_FORMAT); $row->start_time = $this->convert_date($row->start, AEC_DB_DATETIME_FORMAT, AEC_WP_TIME_FORMAT); $row->end_date = $this->convert_date($row->end, AEC_DB_DATETIME_FORMAT, AEC_WP_DATE_FORMAT); $row->end_time = $this->convert_date($row->end, AEC_DB_DATETIME_FORMAT, AEC_WP_TIME_FORMAT); // link to event $class = ($whitelabel) ? '' : ' ' . $row->className; $out .= '<li class="fc-event round5' . $class . '" onClick="jQuery.aecDialog({\'id\':' . $row->id . ',\'start\':\'' . $row->start . '\',\'end\':\'' . $row->end . '\'});">'; $out .= '<span class="fc-event-time">'; $out .= $row->start_date; if (!$row->allDay) { $out .= ' ' . $row->start_time; } $out .= '</span>'; $out .= '<span class="fc-event-title">' . $this->render_i18n_data($row->title) . '</span>'; $out .= '</li>'; } } return $out; }
Now — here is my custom code:
function render_eventlist_events($events, $whitelabel, $limit) { usort($events, array($this, 'array_compare_order')); $rows = $this->convert_array_to_object($events); $out = ''; foreach ($rows as $count => $row) { //if ($count < $limit) { if (!$limit || $count < $limit) { // split database formatted datetime value into display formatted date and time values $row->start_date = $this->convert_date($row->start, AEC_DB_DATETIME_FORMAT, AEC_WP_DATE_FORMAT); $row->start_time = $this->convert_date($row->start, AEC_DB_DATETIME_FORMAT, AEC_WP_TIME_FORMAT); $row->end_date = $this->convert_date($row->end, AEC_DB_DATETIME_FORMAT, AEC_WP_DATE_FORMAT); $row->end_time = $this->convert_date($row->end, AEC_DB_DATETIME_FORMAT, AEC_WP_TIME_FORMAT); // link to event $class = ($whitelabel) ? '' : ' ' . $row->className; $out .= '<li class="fc-event round5' . $class . '" onClick="jQuery.aecDialog({\'id\':' . $row->id . ',\'start\':\'' . $row->start . '\',\'end\':\'' . $row->end . '\'});">'; $out .= '<span class="fc-event-time">'; $out .= $row->start_date; // Show Start-End dates if not equal and not all day; else show start time -- VALERIE LASKOWSKI 10/13/2015 if (!$row->allDay) { $out .= ' ' . $row->start_time; } else { if ($row->start_date!==$row->end_date) { $out .= '-' . $row->end_date; } } // End of FIX by VALERIE LASKOWSKI $out .= '</span>'; $out .= '<span class="fc-event-title">' . $this->render_i18n_data($row->title) . '</span>'; $out .= '</li>'; } } return $out; }
[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been damaged by the forum’s parser.]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Fix to show From-To date range in widget’ is closed to new replies.