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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

EventsHolderPage with by date navigation


Go to End


866 Views

Avatar
karibe

Community Member, 56 Posts

9 September 2009 at 1:26am

Hello

I'd like to navigate throe events on eventsHolder page by navigations links like that:

		<p>
			Select period:<br />
			<select name="">
			<% control eventsNav.months %>
				<option <% if $key==$currentMonth %>selected="selected"<% end_if %> value="$key">$value</option>
                        <% end_control %>
			</select>
<!-- same with years -->
		</p>

What should look like data structure on EventsPageHolder_Controller class to use similar template. I have two hash arrays that should be
pattern for sapphire data structures:

	private $months = array(
		0  => "Jan",
		1  => "Feb",
		2  => "Mar",
	);
	
	private $years = array(
		2008 => 2008,
		2009 => 2009,
		2010 => 2010,
	);

and controller method

 	public function eventsNav()
 	{
 		$result = new DataObjectSet();
		$months = new DataObjectSet();
		$years = new DataObjectSet();
		
		$result->push(array("currentMonth" => $this->month));
		$result->push(array("currentYear" => $this->year));
		return $result;
 	}