Thanks for pointing me in the right direction. Your method worked, but the problem I was running into was that my Menus and some other content disappeared. I looked around and found this thread http://www.silverstripe.org/template-questions/show/252412
I was not able to figure out how their solution was supposed to work :-)
I was able to circumvent this problem by doing the following. The URL structure I left the same /sermons/date/2009-10-15 but instead of creating a date() method, I created a method called GetSermon()
(I did have to change the preg_match and DATE_FORMAT because in the URL the raw SQL date is used and I could not figure out how to change it to m-d-Y, in my custom link structure: $this->SermonHolder()->Link() . 'date/'. $this->sermonDate)
function GetSermon() {
$date = Director::urlParam('ID');
if(!preg_match('/\d{4}-\d{2}-\d{2}/', $date)){
// if date is not properly formatted, return latest entry
return DataObject::get("Sermon", "", "sermonDate DESC", "", "1");
}
$dataObject = DataObject::get_one('Sermon', "DATE_FORMAT(sermonDate, '%Y-%m-%d') = '$date'");
if(!$dataObject){
// if no dataobject, return latest entry
return DataObject::get("Sermon", "", "sermonDate DESC", "", "1");
}
return $dataObject;
}
and the method is called in the template:
<% control GetSermon %>
... data output goes here ...
<% end_control %>
It works, but I'm not sure if there could be any draw backs for doing it this way.
Thanks again Banal for your help!!