silverstripe-event-calendar icon indicating copy to clipboard operation
silverstripe-event-calendar copied to clipboard

Adding $CalenderWidget to another page.

Open reececropley opened this issue 11 years ago • 0 comments

Hi,

I have the extension working fine on the events page of my website. I would like to display the $CalenderWidget on the home page of my website.

In the HomePage.php I have:

class HomePage extends SiteTree {

    public static $db = array(
    );

    public static $has_one = array(
        "MyWidgetArea" => "WidgetArea"
    );

    public function getCMSFields() {
        $fields = parent::getCMSFields();
        $fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("MyWidgetArea"));
        return $fields;
    }

}
class HomePage_Controller extends ContentController {

    /**
     * An array of actions that can be accessed via a request. Each array element should be an action name, and the
     * permissions or conditions required to allow the user to access it.
     *
     * <code>
     * array (
     *     'action', // anyone can access this action
     *     'action' => true, // same as above
     *     'action' => 'ADMIN', // you must have ADMIN permissions to access this action
     *     'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
     * );
     * </code>
     *
     * @var array
     */
    public static $allowed_actions = array (
    );

    public function init() {
        parent::init();

        // Note: you should use SS template require tags inside your templates 
        // instead of putting Requirements calls here.  However these are 
        // included so that our older themes still work

        Requirements::themedCSS('jquery.lightbox-0.5');
        Requirements::themedCSS('nivo-slider');
        Requirements::themedCSS('styles');
    }

    public function CalendarWidget() {
        return Calendar::get()->first()->CalendarWidget();
    }


}

Inside my HomeSideBar.ss (which gets included in the HomePage.ss) I have:

    $CalenderWidget

Yet nothing is displayed on my Home Page of the website. I have the 'widgets' and 'event_calender' extensions on the site. From what I can see these are working fine, I can display the blog widgets fine.

Am I missing anything here? If you need any more information please ask :D

reececropley avatar Aug 27 '13 11:08 reececropley