Jump to:

10928 Posts in 2612 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Event calendar announcements on homepage

Discuss all other Modules here.

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

Page: 1 2
Go to End
Author Topic: 3071 Views
  • Anaya
    Avatar
    Community Member
    42 Posts

    Event calendar announcements on homepage Link to this post

    Hi Guys,

    Just not able to understand how to display annoucements(Event Calendar) on home page...
    And another issue is want to display upcoming events on home page but dont want to include Announcements in it..
    Any suggestions guys...

    Thanks for your help in advance

    Regards
    Anaya...

  • UncleCheese
    Avatar
    4085 Posts

    Re: Event calendar announcements on homepage Link to this post

    Try:

    public function UpcomingAnnouncements()
    {
    return DataObject::get_one("Calendar")->upcomingEvents(5, "is_announcement = 1");
    }

    public function UpcomingNonAnnouncements()
    {
    return DataObject::get_one("Calendar")->upcomingEvents(5, "is_announcement = 0");
    }

  • Anaya
    Avatar
    Community Member
    42 Posts

    Re: Event calendar announcements on homepage Link to this post

    Thanks UncleCheese,

    The first function is working fine...it displays only announcements...
    But the second function displays both announcements and events..it should display only events..shouldnt it???
    The code I am using on page.ss is -
    <% control UpcomingNonAnnouncements %>
    <ul>
    <li>
    <span>$_Dates</span><br/>
    <a href=$Link">$EventTitle</a></li>
    </ul>
    <% end_control %>

    Regards
    Anaya...

  • Anaya
    Avatar
    Community Member
    42 Posts

    Re: Event calendar announcements on homepage Link to this post

    Hi UncleCheese,

    The function for displaying only events works fine.
    Only difference is using it in template . Instead of the code I have mentioned in my above post, it should be -
    <% control UpcomingNonAnnouncements %>
    <% if Event %>
    <ul>
    <li>
    <span>$_Dates</span><br/>
    <a href=$Link">$Event.Title</a></li>
    </ul>
    <% end_if %>
    <% end_control %>

    Thanks for your help....

    Regards

  • jodamo5
    Avatar
    Community Member
    9 Posts

    Re: Event calendar announcements on homepage Link to this post

    Hi. I've tried to follow the instructions here. I have declared this public function

    public function UpcomingNonAnnouncements()
    {
    return DataObject::get_one("Calendar")->upcomingEvents(5, "is_announcement = 0");
    }

    in this file:
    event_calendar/code/Calendar.php

    Is that right?

    I have then inserted this code into my siderbar:
    <% control UpcomingNonAnnouncements %>
    <ul>
    <li>
    <span>$_Dates</span><br/>
    <a href=$Link">$EventTitle</a></li>
    </ul>
    <% end_control %>

    But nothing shows up at all.

    Can you tell me what I've done wrong?

    thanks heaps!

  • UncleCheese
    Avatar
    4085 Posts

    Re: Event calendar announcements on homepage Link to this post

    A couple things I would try. First, try just <% control UpcomingEvents %> and see if that does anything. Also, make sure that if the function is in Calendar.php that the function is in the Calendar_Controller. You can put it in Page_Controller to make it globally accessible. Also, make sure when the function is called on the template that you're not in any nested controls. That should be at the top level.

    Lastly, in your function, just put a var_dump on the output and see if it's returning a DOS at all or if it's returning false.

  • jodamo5
    Avatar
    Community Member
    9 Posts

    Re: Event calendar announcements on homepage Link to this post

    Hi. The <% control UpcomingEvents %> control is actually more what I was wanting anyway. I just didn't find it when I was searching. But I've put that on my page (now straight in my main page.ss file - just for testing to make sure it isn't inside anything it shouldn't be - but still no luck. Nothing showing up at all.

    I found the Calendar_Controller within Calendar.php and moved the UpcomingNonAnnouncements() public function inside that. But still nothing is showing with that either.

    In regards to the var_dump, can you please give me the exact code? I'm very much a beginner and have looked up var_dump() but I don't know what to put in the brackets.

    so this is my public function:
    public function UpcomingNonAnnouncements()
       {
          return DataObject::get_one("Calendar")->upcomingEvents(5, "is_announcement = 0");
       }

    How do I put a var_dump in there. And what and where should I expect to see this information on screen?

    Sorry I got lost. Thanks for the help.

  • jodamo5
    Avatar
    Community Member
    9 Posts

    Re: Event calendar announcements on homepage Link to this post

    Hi - another update.
    I have changed my code in my sidebar to include a line to write if there are no events. This is my new code:
    <% if Events %>
    <% control UpcomingNonAnnouncements %>
    <ul>
    <li>
    <span>$_Dates</span><br/>
    <a href=$Link">$EventTitle</a></li>
    </ul>
    <% end_control %>
    <% else %>
    <% _t('NOEVENTS','There are no events to show in the list') %>.
    <% end_if %>

    Sure enough, it is displaying my "noevents" text ... even though there are events in the calendar that SHOULD be displaying in the list. So no data is getting through for some reason.

    Is it still useful to do a var_dump? (And how do I do that?)

    How can I get this data to show up like it should?

    Thanks!

    3071 Views
Page: 1 2
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.