Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Widgets /

Discuss SilverStripe Widgets.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Customising content with a widget (LiveCalendarWidget)

Go to End



Community Member, 323 Posts

1 November 2009 at 6:19am


I have a modified LiveCalendarWidget (thanks UncleCheese!) that I can include in with $LiveCalendarWidget, but I can’t use the technique described in this recipe for customising $Content:

class ActivityPage_Controller extends CalendarEvent_Controller {

	protected function Widget($type) {
		if($date = CalendarUtil::getDateFromURL())
			$date_obj = new sfDate($date);
		elseif($date = DataObject::get_one($this->getDateTimeClass(),"EventID = {$this->ID}", "StartDate ASC"))
			$date_obj = new sfDate($date->StartDate);
			return false;

		// $this->Parent() for obtaining all ActivityHolder events (ActivityPage)
		//return new $type($this->Parent(),$date_obj,$date_obj);
		return new $type($this,$date_obj,$date_obj);

	public function LiveCalendarWidget() {
		return $this->Widget('LiveCalendarWidget');

	// This should allow for inserting the LiveCalendarWidget in the page content
	function Content() {
		return str_replace('$LiveCalendarWidget', $this->LiveCalendarWidget(), $this->Content);

This code renders nothing in place of the string $LiveCalendarWidget inserted in the Content field through the CMS. If I specify the template to be used:

function Content() {
	return str_replace('$LiveCalendarWidget', $this->LiveCalendarWidget()->renderWith("LiveCalendarWidget"), $this->Content);

The page breaks because LiveCalendarWidget’s controls and variables are not found: Object->__call(): the method 'getweeks' does not exist on ''. Does not exist where? SS does not even know it and outputs a single ".

I don’t know what I’m doing wrong, the recipe says that the template used in renderWith() can contain HTML or PHP, but certainly SS controls are not in this category.

So, it is possible to customise Content with Widgets?

Thanks in advance,