22427 Posts in 6976 Topics by 2750 members
General questions about getting started with SilverStripe that don't fit in any of the categories above.
|Go to End|
11 September 2011 at 12:28pm Last edited: 11 September 2011 12:28pm
I'm trying to write a wrapper function in a page class to get the most recent Calendar page, then call the Events() function on that since Calendar.php has an Events function. I tried the following:
$cal = DataObject::get("Calendar", "", "Created DESC", "", 1);
I get the error:
[User Error] Uncaught Exception: Object->__call(): the method 'events' does not exist on 'DataObjectSet'
I assume it's because DataObject::get returns a DataObjectSet that contains the Calendar object in it. If that's the case, how do I get the Calendar object from that where I can call its Events() method? If I'm wrong, how would I go about accomplishing what I'm trying to do?
Thanks for any help.
11 September 2011 at 6:12pm
If you only need to retrieve one object, then why not use DataObject::get_one? That should return a single DataObject instead of a DataObjectSet and I think your event method should be available then.
|Go to Top|