10446 Posts in 2223 Topics by 1719 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 999 Views |
-
Use Event Calendar module in Includes for custom sidebar

27 April 2010 at 10:43pm
I've installed the Events Calendar module, which is working fine. The site I'm building has various items such as a booking form and events diary which are included in the sidebar. I need have an include which displays the $MonthNavigator with a set amount of upcoming events under it which I can include on any page that required it throught the site.
Does anyone know how this can be achieved?
-
Re: Use Event Calendar module in Includes for custom sidebar

28 April 2010 at 1:45am
The functions UpcomingEvents(), RecentEvents(), CalendarWidget() and LiveCalendarWidget() are all decorated into your SiteTree class, so you can call them anywhere. MonthNavigator() was not, but I have added it into the trunk (2.4 only).
It's easy enough to do it yourself, though..
return new MonthNavigator($your_calendar_object, new sfDate());
-
Re: Use Event Calendar module in Includes for custom sidebar

28 April 2010 at 9:12pm
Thanks for the reply. But I still can't seem to acheive what I'm looking for.
In my Page_Controller in Code/Page.php i have
function EventsDiary(){
MonthNavigator($(this), new sfDate());
}and in my includes/sidebar.ss I have
<div>
$EventsDiary
</div>This displays the drop down box, but tried to redirect me to another page. I wan't to be able to select a month and it show me events in that month inside my sidebar, I've attached a png of what I'm trying to acheive.
Thanks.
-
Re: Use Event Calendar module in Includes for custom sidebar

29 April 2010 at 1:27am Last edited: 29 April 2010 1:28am
This is not PHP syntax:
$(this)
That's jQuery.
Your function isn't returning anything.
public function EventsDiary(){
return new MonthNavigator($this, new sfDate());
}But if you're going to have this globally accessible, you can't use $this, because you don't know what page you're going to be on. So you need to pass it an object of the calendar you want to use.
DataObject::get_one("Calendar") for instance.. or whatever you're using.
-
Re: Use Event Calendar module in Includes for custom sidebar

29 April 2010 at 10:29pm
When including lists of events its useful to be able to filter which ones will appear through the cms. This can be done by changing getEventIds() to the following;
protected function getEventIds()
{
$ids = array();
if($children = $this->Children()) {
if(!$this->site_mode='cms'){
foreach($children as $child)
$ids[] = $child->ID;
return $ids;
}else{
// 'I dont trust you with my children'
//or joined if($children = DataObject::get("SiteTree", "ParentID='".$this->ID."' AND ShowInSearch=1","Created")) {
$sqlQuery = new SQLQuery("ID","SiteTree","ParentID='".$this->ID."' AND ShowInSearch=1");
$results=$sqlQuery->execute();
foreach($results as $child)
$ids[] = $child['ID'];
return $ids;
}
} else {
return false;
}
}Can something like this be put into the next release?
-
Re: Use Event Calendar module in Includes for custom sidebar

30 April 2010 at 2:01am
That whole function is ugly. I can't see how getEventIDs() would make it into the next release in any form. It's just bad practice.
| 999 Views | ||
|
Page:
1
|
Go to Top |

