Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

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

Event calendar announcements on homepage


Go to End
Reply


14 Posts   3311 Views

Avatar
Anaya

Community Member, 42 Posts

10 June 2009 at 2:51am

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...

Avatar
UncleCheese

Forum Moderator, 4094 Posts

10 June 2009 at 3:03am

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");
}

Avatar
Anaya

Community Member, 42 Posts

10 June 2009 at 7:55pm

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...

Avatar
Anaya

Community Member, 42 Posts

18 June 2009 at 10:14pm

Edited: 18/06/2009 10:15pm

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

Avatar
jodamo5

Community Member, 9 Posts

2 December 2009 at 10:36pm

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!

Avatar
UncleCheese

Forum Moderator, 4094 Posts

3 December 2009 at 3:14am

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.

Avatar
jodamo5

Community Member, 9 Posts

3 December 2009 at 9:53pm

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.

Avatar
jodamo5

Community Member, 9 Posts

3 December 2009 at 10:33pm

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!

Go to Top