WordPress.org

Ready to get started?Download WordPress

Forums

WP Calendar
Display enddate and endtime with one tag (1 post)

  1. nacamar
    Member
    Posted 2 years ago #

    If I use the following code for example to display events as a list
    {event_subject} @ {event_location}<br />{event_startdate} { event_starttime} – {event_enddate} {event_endtime}
    all day events have always a "-" character at the end, because an enddate is not displayed with default settings.

    As a solution I added a further Tag: {event_enddatetime}

    Here is the code you have to add into fsCalendar.php in function filterContent($content, $evt = NULL):

    case 'enddatetime':
    if (!empty($evt->to) && $evt->to != '0000-00-00 00:00:00') {
    	if (isset($opts['alwaysshowenddate']))
    	$l_sed = ($opts['alwaysshowenddate'] == true ? true : false);
    	else
    	$l_sed = $showenddate;
    
    	if (isset($opts['hideifallday']))
    	$l_hide = ($opts['hideifallday'] == true ? true : false);
    	else
    	$l_hide = $hideifallday;
    
    	// Do not display date if from AND to is the same
    	if ($l_sed == false &&
    	( mysql2date('d', $evt->to) == mysql2date('d', $evt->from) &&
    	mysql2date('m', $evt->to) == mysql2date('m', $evt->from) &&
    	mysql2date('Y', $evt->to) == mysql2date('Y', $evt->from) )) {
    		$rep = '';
    	} else {
    		if (isset($opts['fmtd']))
    		$rep .= $evt->getEnd($opts['fmtd'], 2);
    		else
    		$rep .= $evt->getEnd('', 2);
    	}
    	// Do not display time if from AND to is the same
    	if (($evt->allday == true && $l_hide == true) ||
    	($l_sed == false && $evt->from == $evt->to)) {
    		$rep .= '';
    	} else {
    		if (isset($opts['fmtt']))
    		$rep .= " " . $evt->getEnd($opts['fmtt'], 3);
    		else
    		$rep .= " " . $evt->getEnd('', 3);
    	}
    } else {
    	$rep = '';
    }
    if (!empty($rep)) {
    	if (isset($opts['before']))
    		$rep = $opts['before'] . " " . $rep;
    }
    break;

    So you can use the Tag as follows:
    {event_subject} @ {event_location}<br />{event_startdate} { event_starttime} {event_enddatetime; fmtd=d.m.Y; fmtt=H:i; before=-}

    You can set extra formats for date and time with fmtd and fmtt. And the "-" is only prefixed if there is a enddate or enttime or both.

    Maybe there are some things to fix, but for me it works at the moment.

    So have fun.

    http://wordpress.org/extend/plugins/wp-calendar/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic