Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Event Calendar issues when only a start date


Go to End


1919 Views

Avatar
plushtoy

Community Member, 10 Posts

22 October 2010 at 5:09am

I am having an issue with an event calendar. When the event is a one day event and has only a start date (no end date), the event does not display and the next event in line repeats. Can anyone explain what I can change in the code to fix the issue.

EventLandingPage.ss

<% if UpcomingEvents(4) %>
			<h3><a href="events"><span>view all</span></a>Upcoming Events</h3>
			<% control UpcomingEvents(4) %>
				<div class="news-module">
					<% if EventURL %><a href="$EventURL" class="logo"><% end_if %>
						<% if EventImage %>$EventImage<% end_if %>
					<% if EventURL %></a><% end_if %>
					<p>
						<span class="date">
						<% if EventEndDate %>
						$EventStartDate.MonthAndDay -
						<% else %>
						$EventStartDate.Complete
						<% end_if %>
						<% if EventEndDate %>$EventEndDate.Complete<% end_if %>
						</span><br/>
						<% if EventURL %><a href="$EventURL"><% end_if %><strong>$EventName</strong><% if EventURL %></a><% end_if %>
						<% if EventDescription %><br/>$EventDescription<% end_if %>
						<% if EventCity %><br/>$EventCity<% end_if %>
					</p>
					<div class="clear"></div>
				</div>
			<% end_control %>
		<% else %>
			<p>There are currently no events scheduled.</p>
		<% end_if %>

EventPage.ss

<% if Events %>
		<h3>Upcoming Events</h3>
		<ul>
			<% control Events %>
			<li>
				<% if EventURL %><a href="$EventURL" target="_blank"><% end_if %><% if EventImage %>$EventImage.SetWidth(100)<% end_if %> <h4>$EventName</h4><% if EventURL %></a><% end_if %><br />
				$EventStartDate.Standard<% if EventEndDate %> - $EventEndDate.Standard<% end_if %> <br />
				<% if Location %>
				by <strong>$Location</strong><br />
				<% end_if %>
				<% if City %>
				$City
				<% end_if %>
				<% if EventDescription %>
				$EventDescription
				<% end_if %>
			</li>
			<% end_control %>
		</ul>
		<% end_if %>

Event.php

<?php 

class Event extends DataObject { 
	
	static $db = array( 
		'EventName' => 'Text',
		'EventStartDate' => 'Date',
		'EventEndDate' => 'Date',
		'EventLocation' => 'Text',
		'EventCity' => 'Text',
		'EventDescription' => 'Text',
		'EventURL' => 'Text',
		'EventMediaURL' => 'Text'
	);

	static $has_one = array(
		'EventImage' => 'Image',
		'EventFile' => 'File',
		'EventHolder' => 'EventHolder'
	);

	static $field_names = array(
		'EventName' => 'Event Name',
		'EventStartDate' => 'Start Date',
		'EventEndDate' => 'End Date',
		'EventLocation' => 'Location/Venue',
		'EventCity' => 'City',
		'EventDescription' => 'Description',
		'EventImage' => 'Image/Logo',
	);

	public function getCMSFields_forPopup() {

		$fields = new FieldSet();

		$fields->push(new TextField('EventName', 'Event Name'));
		$fields->push(new CalendarDateField('EventStartDate', 'Start Date'));
		$fields->push(new CalendarDateField('EventEndDate', 'End Date'));
		$fields->push(new TextField('EventLocation', 'Location/Venue'));
		$fields->push(new TextField('EventCity', 'City'));
		$fields->push(new TextAreaField('EventDescription', 'Description'));
	    $fields->push(new ImageField('EventImage', 'Event Image/Logo'));
	    $fields->push(new TextField('EventURL', 'Link/URL of Venue, Company, or Organization'));
		$fields->push(new FileIFrameField('EventFile', 'Download File'));
	    $fields->push(new TextField('EventMediaURL', 'Link/URL to Video or Audio'));

		return $fields;

	}
	
	function GetFileTypeText() {
		//echo($this->EventImage.Filename);
	}
} 

class Event_Controller extends Page_Controller {
	
}