Jump to:

794 Posts in 409 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » Customising content with a widget (LiveCalendarWidget)

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 1565 Views
  • Juanitou
    Avatar
    Community Member
    323 Posts

    Customising content with a widget (LiveCalendarWidget) Link to this post

    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

    1565 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.