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.

All other Modules /

Discuss all other Modules here.

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

[Solved] EventCalendar OtherDates totals


Go to End


2 Posts   1250 Views

Avatar
mathiasmex

Community Member, 28 Posts

19 November 2009 at 1:51am

Edited: 19/11/2009 11:16pm

Hi Uncle Cheese,

maybe you can help me out (please ?).

I'm trying to show the total amount of days for an event in the template using following code:


Workshop.ss

	<% if Dates %>
		<% control Dates %>
			<% if TotalItems == 1 %>
				<% if OtherDates %>
					<% control OtherDates %>
						<% if First %>
							<dt>$TotalItems Termine</dt>
						<% end_if %>
					<% end_control %>
				<% else %
					<dt>$TotalItems Termin</dt>
				<% end_if %>
			<% else %>
				<% if TotalItems == 1 %>
					<dt>$TotalItems Termine</dt>
				<% else %>
					<% if First %>
						<dt>$TotalItems Termine</dt>
					<% end_if %>
				<% end_if %>
			<% end_if %>
		<% end_control %>
	<% end_if %>

When I enter an event from 08/24 up to 10/26, recurring every Monday, the code above results in a total of 8 times, which actually should result in a total of 10. This because I'm in the loop of OtherDates. Any idea on how to get the real amount of times, e.g. 10 ?

Thanks in advance for any suggestion.

mathiasmex

Avatar
mathiasmex

Community Member, 28 Posts

19 November 2009 at 11:20pm

Ok, found the solution:

just included in WorkshopDateTime.php:


public function TotalItemsCounter() {
	return ($this->iteratorTotalItems + 2);
}

and altered Workshop.ss as follows:


<% if OtherDates %>
	<% control OtherDates %>
		<% if First %>
			<dt>$TotalItemsCounter Termine</dt>
		<% end_if %>
	<% end_control %>
<% else %>
	<dt>$TotalItems Termin</dt>
<% end_if %>

Thanks to ssbits.

mathiasmex