Hi!
I have a modified LiveCalendarWidget (thanks UncleCheese!) that I can include in ActivityPage.ss 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);
else
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,
Juan