WordPress.org

Forums

Simple Events Calendar
[resolved] No upcoming events error message (3 posts)

  1. ryancon18
    Member
    Posted 4 years ago #

    When I have no events with a given label the pages has an error message of

    Warning: implode() [function.implode]: Argument must be an array in /home/content/89/7031489/html/(omited)/wp-content/plugins/simple-events-calendar/simple-events-calendar.php on line 730

    Is their a way for it to say something like "no upcoming events" or just be blank if nothing is inputed.

    http://wordpress.org/extend/plugins/simple-events-calendar/

  2. vlasaga
    Member
    Posted 4 years ago #

    Hey, I see you posted this a month ago. Not sure if you found a solution or not, but for anyone who is looking for a solution to get the error from being displayed, I have an answer. It's a simple fix really.

    Here is the original line of code in the "simple-events-calendar.php" file:

    $the_events[] =
    		'<ul style="list-style:none; padding:0 0 0 15px; margin:10px 0;" class="vevent"><li style="list-style:none;"><h3 class="summary" style="margin:0;">'.
    		stripslashes($event['event_title']).
    		'</h3></li><li class="description" style="list-style:none;">'.
    		stripslashes($event['event_desc']).
    		'</li><li style="list-style:none;"><span style="font-weight:bold;">'.__('When:',SE_TEXTDOMAIN).' </span><abbr class="dtstart" title="'.
    		date('Y-m-d',$event['event_start']).'T'.date('H:i',$event['event_start']).
    		'">'.
    		$eventtime.
    		'</abbr> - <abbr class="dtend" title="'.
    		date('Y-m-d',$event['event_end']).'T'.date('H:i',$event['event_end']).
    		'">'.
    		strftime( __('%H:%M',SE_TEXTDOMAIN),$event['event_end']).
    		'</abbr>'.
    		'</li>'.
    		$evt_loc.
    		$evt_url.
    		'</ul>';
    	} // end foreach ($allevents as $event)
    	$items = implode($the_events);
    	return($items);

    You need to change it to an 'if' statement to find out whether we have a title(which is a required field) of an event, and if so, carry out the original code. Then you just add an 'else' statement that basically tells it to do nothing.

    Final code:

    if ($event['event_title']) {
    		$the_events[] =
    		'<ul style="list-style:none; padding:0 0 0 15px; margin:10px 0;" class="vevent"><li style="list-style:none;"><h3 class="summary" style="margin:0;">'.
    		stripslashes($event['event_title']).
    		'</h3></li><li class="description" style="list-style:none;">'.
    		stripslashes($event['event_desc']).
    		'</li><li style="list-style:none;"><span style="font-weight:bold;">'.__('When:',SE_TEXTDOMAIN).' </span><abbr class="dtstart" title="'.
    		date('Y-m-d',$event['event_start']).'T'.date('H:i',$event['event_start']).
    		'">'.
    		$eventtime.
    		'</abbr> - <abbr class="dtend" title="'.
    		date('Y-m-d',$event['event_end']).'T'.date('H:i',$event['event_end']).
    		'">'.
    		strftime( __('%H:%M',SE_TEXTDOMAIN),$event['event_end']).
    		'</abbr>'.
    		'</li>'.
    		$evt_loc.
    		$evt_url.
    		'</ul>';
    		$items = implode($the_events);
    		}
    		else {
    		$items = "";
    		}
    	} // end foreach ($allevents as $event)
    	return($items);

    It should work. Let me know if it is doing otherwise. Cheers!

  3. Jerry G. Rietveld
    Member
    Plugin Author

    Posted 4 years ago #

    Hi guys,

    Sorry for my late response. Thanks vlasaga for proving a fix. I've just submitted a big update for the Simple Events Calendar plugin which, among many things, fixes this issue.

    Cheers!

    Jerry

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Simple Events Calendar
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic