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.

General Questions

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

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

EventsHolderPage with by date navigation


Reply

474 Views

Avatar
karibe

9 September 2009 at 1:26am Community Member, 56 Posts

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;
   }