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 Widget on Home page


Reply


34 Posts   6820 Views

Avatar
elgordo

Community Member, 70 Posts

25 April 2011 at 1:55am

Thanks for the info - resolved the issue I was having in getting a global calendar showing :)

Avatar
tchintchie

Community Member, 63 Posts

2 May 2011 at 3:59am

Hello all!

I´m running a site for our small travel agency so I thought it would be nice to have the upcoming events posted on the HomePage. The calendar works fine on it´s calendarpage but how do I get it to work on the HomePage? I followed your little tutorial here and it got me the calendar widget which isn´t what i want.
Is there a possibility to e.g. post 5 upcoming events (without the calendar widget) on my HomePage? Can someone give me the codes for the HomePage.php and HomePage.ss ???

many thanks in advance
kind regards
tchintchie

Avatar
UncleCheese

Forum Moderator, 4096 Posts

2 May 2011 at 2:02pm

<% control UpcomingEvents%>
$_Dates $EventTitle $Link
<% end_control%>

Avatar
tchintchie

Community Member, 63 Posts

3 May 2011 at 2:21am

UncleCheese, thanks for the code. But obviously it´s not enough to just simply paste it into my HomePage.ss ?? Is there something else I need to add to my HomePage.php? here´s what it looks like at the moment:

<?php
/**
* Defines the HomePage page type
*/
class HomePage extends Page {
static $db = array(
);
static $has_one = array(
);
function LatestNews($num=5) {
$news = DataObject::get_one("ArticleHolder");
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
}
static $icon = "themes/tutorial/images/treeicons/home";
}
class HomePage_Controller extends Page_Controller {
   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);
}
}

sorry for being a noob :-/

thanks in advance!

Avatar
UncleCheese

Forum Moderator, 4096 Posts

3 May 2011 at 6:23am

No, that function is decorated into your SiteTree class, so you don't need to write any code. It's added automatically by the module.

Avatar
tchintchie

Community Member, 63 Posts

3 May 2011 at 7:56am

*sigh* thanks so much for the quick reply and your patience...however I really meant it when I said "noob" :-D Ok, so I decorated the above mentioned functions of the calendar-code to my SiteTree.php (so far so good?)
I did a dev/build --> nothing happened. Added
<% control UpcomingEvents%>
$_Dates $EventTitle $Link
<% end_control%>
to my HomePage.ss and ran a dev/build again. Still nothing.
I really feel bad about bothering you with my noob-problems but it would be such a nice feature. But it seems I need a step-by-step tutorial on that. Anyone has pity on me??

thanks again :)

Avatar
UncleCheese

Forum Moderator, 4096 Posts

3 May 2011 at 11:41am

No, you shouldn't have to do any decorating. The module does it for you. That control block should work out of the box.

Avatar
tchintchie

Community Member, 63 Posts

7 May 2011 at 1:02am

alright, found another (older) post where someone intented to do the same. I even got the upcoming events working on my homepage BUT...when I click on the event link it gives me the error page. I´ve read that this issue was supposed to be fixed with a SVN update but since I just recently downloaded that module I don´t think there´s a newer version? btw those posts where from 2009 ... :-/ maybe not compatible with SS 2.4.5??