Jump to:

10931 Posts in 2614 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » Event Calendar Widget on Home page

Discuss all other Modules here.

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

Page: 1 2 3 4 5
Go to End
Author Topic: 6316 Views
  • Anaya
    Avatar
    Community Member
    42 Posts

    Event Calendar Widget on Home page Link to this post

    Hi Guys,

    I have been trying to put actual calendar on home page.
    As mentioned in one of the threads, have put following code in Homepage.php in controller block -
    function GlobalCalendarWidget()
    {
    $calendarPage = DataObject::get_one("Calendar"); // If you have multiple calendars, specify an id or url segment.
    return new CalendarWidget($calendarPage);
    }

    But really dont have any idea how to call it in template.
    Can I do tht? And if yes, whats the syntax for calling it in template.
    Have tried lot of options like $CalendarWidget...but that still does not work..

    I know its very basic thing...but dont know how to do that.
    Need your help!

    Regards
    Anaya...

  • UncleCheese
    Avatar
    4085 Posts

    Re: Event Calendar Widget on Home page Link to this post

    $GlobalCalendarWidget is what you want. If that's not working, post your template and homepage controller code.

  • Anaya
    Avatar
    Community Member
    42 Posts

    Re: Event Calendar Widget on Home page Link to this post

    Hi UncleCheese,

    Even I had tried $GlobalCalendarWidget, but after flushing the pag, blank page appears.
    As asked, here is the homepage.php code -

    <?php
    /**
    * Defines the HomePage page type
    */

    class HomePage extends Page {
    static $db = array(
    'AnnouncementText' => 'HTMLText'
    );
    static $has_one = array(
    );

       function getCMSFields()
       {
       $fields = parent::getCMSFields();
       $fields->addFieldToTab('Root.Content.Announcement', new HtmlEditorField('AnnouncementText', 'Announcement'));
       return $fields;
       }   
    }

    class HomePage_Controller extends Page_Controller {
    function LatestNews($num=3) {
    $news = DataObject::get_one("ArticleHolder");
    return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
    }

    function UpcomingEvents()
    {
    return DataObject::get_one("Calendar")->upcomingEvents(5);
    }

    function GlobalCalendarWidget()
    {
    $calendarPage = DataObject::get_one("Calendar"); // If you have multiple calendars, specify an id or url segment.
    return new CalendarWidget($calendarPage);
    }
       
    }
    ?>

    Code for homepage template which is in Layout folder -
    <div id="contentLeft">
    $Content
    $Form
    </div>
    <div id="contentRight">
    <h3>News</h3>
    <div class="marquee_text"><marquee scrolldelay = "100"><p>$AnnouncementText</p></marquee>
    </div>
    <div class="NewsListHomeIn">
    <% control LatestNews %>
    <a href="$Link" title="$Title" class="newsTitle">$Title</a>
    <div class="news_img">$Photo.SetWidth(75)</div>
    <div class="news_text">
    $Content.LimitWordCount(10)<br/>
    <a href="$Link" title="Read more on &quot;{$Title}&quot;">Read more &gt;&gt;</a>
    </div>
    <div class="clear"></div>
    </div>
    <% end_control %>
    </div>
    $GlobalCalendarWidget
    </div>
    <div class="clear"></div>

    Regards

  • UncleCheese
    Avatar
    4085 Posts

    Re: Event Calendar Widget on Home page Link to this post

    Blank page usually means a PHP error. Can you crank up your error reporting or check your logs for what it might be throwing?

  • Anaya
    Avatar
    Community Member
    42 Posts

    Re: Event Calendar Widget on Home page Link to this post

    Hey,
    I cant find out whts wrong in php code???
    PHP error means in Homepage.php page...right???
    Any idea abt wht could be wrong in the php code...

    Regards

  • Anaya
    Avatar
    Community Member
    42 Posts

    Re: Event Calendar Widget on Home page Link to this post

    Hi Guys,

    As mentioned in my other post, Event calendar is appearing in Firefox...
    [link]http://silverstripe.org/all-other-modules/show/261483#post261483[/link]
    But I am not able to get it working on home page...
    Earlier upcoming events were appearing, but after using code from below link, it stopped working...
    [link]http://bluehousegroup.svn.beanstalkapp.com/modules/trunk/event_calendar/ [/link]
    The code in HomePage.php -
    function GlobalCalendarWidget()
    {
    $calendarPage = DataObject::get_one("Calendar"); // If you have multiple calendars, specify an id or url segment.
    return new CalendarWidget($calendarPage);
    }
    function UpcomingEvents()
    {
    return DataObject::get_one("Calendar")->upcomingEvents(5);
    }

    Pls pls let me know wht wrong i am doing???
    I have been working on this for two days...need to sort out this urgently...

    Regards
    Bhagyashri

  • UncleCheese
    Avatar
    4085 Posts

    Re: Event Calendar Widget on Home page Link to this post

    The GlobalCalendarWidget() function needs to be in a controller. Put it in the Page_Controller to have the most flexibility. Then you can put it on any page you want.

  • Anaya
    Avatar
    Community Member
    42 Posts

    Re: Event Calendar Widget on Home page Link to this post

    Thanks UncleCheese,

    for your suggestion...
    its working fine now...

    regards
    anaya.

    6316 Views
Page: 1 2 3 4 5
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.