On Fri, Jun 18, 2010 at 8:44 AM, Matt Spendlove
<[email protected]> wrote:
> Hi all
>
> I have a News page of archive page type. Users can tag the pages into
> "news", "events", "offers" etc.
> I'd like to be able to show upcoming events in a sidebar.
>
> I can search for all items tagged with "events" and display them, but
> how do I show only events where <r: date> >= TODAY ?
>
> I didn't really want to go down the route of using a dedicated
> calendar extension [1] as it's overkill for the requirements. I can't
> see to be able to do any kind of conditional fiter on the date?
>
> Your thoughts appreciated.
>
> Matt
>
>
> [1] http://github.com/davec/radiant-events-calendar-extension
>
There's no notion of "upcoming" with the archive pages.
To do this, you'll need to create an new tag (in a custom extension).
Here's some quick code that should get you along:
tag 'upcoming' do |tag|
tag.locals.upcoming = Page.all(:conditions => ['whatever_date > ?',Time.now]
tag.expand
end
tag 'upcoming:each' do |tag|
result = []
tag.locals.upcoming.each do |page|
tag.locals.page = page
result << tag.expand
end
result
end
--
Jim Gay
Saturn Flyer LLC
http://www.saturnflyer.com
571-403-0338