18590 Posts in 4875 Topics by 2285 members
General Questions
SilverStripe Forums » General Questions » EventPage sorted by date - howto show only until today?
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 844 Views |
-
EventPage sorted by date - howto show only until today?

22 February 2011 at 5:00am
Hi,
I have a problem with sorting by date...perhaps someone can help me out?
I have a EventHolder and a EventPage
in EventHolder.php i am sorting AllChildren() by a Date field
function SortedChildren(){
$children = $this->AllChildren();
if( !$children )
return null;
$children->sort('Date', 'ASC');
return $children;
}in EventHolder.ss i list those EventPages
<% control SortedChildren %>
<h2><a href="$Link">$Date.Format(d.m.Y) - $Title</a></h2>
<p>$Content.FirstParagraph<a class="arrow" href="$Link">weiter</a></p>
<% end_control %>Now i want only to show EventPages with future dates. Old events should no longer be listed wen they are in the past.
Any idea?
Thanks much!
patte
-
Re: EventPage sorted by date - howto show only until today?

23 February 2011 at 5:07pm
Patte,
Try this:function AllFutureChildren() {
$littlechildren = DataObject::get("EventPage", "Date >= CURDATE()", "Date ASC", null, null);
return $littlechildren;
}add it to page.php so its accessible from all pages on the site.
-
Re: EventPage sorted by date - howto show only until today?

14 March 2011 at 11:30pm
Thanks Bruce B ;-)
Works like a charm.
| 844 Views | ||
|
Page:
1
|
Go to Top |


