Events Overview

<% counter=0 events = @pages.find(:all , :in_directory => @page.dir, :recursive => true, :sort_by => "period", :reverse => true, :event => true)

require 'date'

events.sort! {|x,y| begin_date_x=Date.strptime(x.period.split(" - ").first.strip,"%d/%m/%Y") begin_date_y=Date.strptime(y.period.split(" - ").first.strip,"%d/%m/%Y") begin_date_y <=> begin_date_x }

-%>

<%

upcoming_header_shown=false past_header_shown=false

paginate(events, 30) do |event| counter=counter+1

if (!upcoming_header_shown && Date.strptime(event.period.split(" - ").first.strip,"%d/%m/%Y") > Date.today)  

-%>

Upcoming trainings

<% upcoming_header_shown=true end

if (!past_header_shown && Date.strptime(event.period.split(" - ").first.strip,"%d/%m/%Y") < Date.today) 

-%>


Past trainings

<% past_header_shown=true end -%>

<%= event.title %> - (<%= event.period %>)

<%= event.short %>


<% end -%>

<%= link_to("Prev", @pager.prev) if @pager.prev? %> <%= link_to("Next", @pager.next) if @pager.next? %>