Page 1 of 1

Calendar Details - Previous or Next Event?

Posted: Thu Feb 21, 2008 9:23 pm
by BobX
Using CMS MS with Calendar 0.7.13. with default templates

In my Detail page, it has the "Previous" and "Next" above the event(s). When hit, they go to the "Previous/Next" Month. Is it possible for them to go to the previous/next Event instead? I looked at the List Template, and didn't see how to make that work.

Not as big a deal, but how do I change the date set up in the details. currently it reads "14 February 2008 to 16 February 2008", and I would prefer "February 14 2008 to February 16 2008"

Thanks for any help!

Bob

Re: Calendar Details - Previous or Next Event?

Posted: Mon Feb 25, 2008 4:52 pm
by BobX
Hi again,

Anyone have any ideas about the above post?

Thanks

Re: Calendar Details - Previous or Next Event?

Posted: Fri Aug 01, 2008 12:00 am
by Raney
I'd also like to change the prev and next links in the day view. Would some kind soul please write out the line of code I need to have the links go to the previous/next day or event instead of month?

Thanks muchly.

Re: Calendar Details - Previous or Next Event?

Posted: Fri Aug 01, 2008 2:52 am
by sn3p
I wanted the same thing, but didn't succeed to navigate to the next/previous event.
The same problem occurred when listing the events for a single day, which you will get when a day in the calendar is clicked. I wrote some custom code which will create navigation links to the next/previous day. Keep in mind I've only tested this with listing events, not with the event detail page. But maybe this code can also be used for the detail page, who knows ;)

Here is what you do:
Open function.displaylist.php and find the following lines (around line 219):

Code: Select all

$navigation['next'] = $module->CreateLink($id, 'default', $returnid, '', array('year'=>$next_month['year'], 'month'=>$next_month['month']), '', true, true, '', false );
$navigation['prev'] = $module->CreateLink($id, 'default', $returnid, '', array('year'=>$prev_month['year'], 'month'=>$prev_month['month']), '', true, true, '', false );
Replace these lines with:

Code: Select all

if ($day > 0) {
	$prev_day['timestamp'] = strtotime("-1 day", mktime(0,0,0,$month, $day, $year));
	$prev_day['day'] = date('j', $prev_day['timestamp']);
	$prev_day['month'] = date('n', $prev_day['timestamp']);
	$prev_day['year'] = date('Y', $prev_day['timestamp']);
	
	$next_day['timestamp'] = strtotime("+1 day", mktime(0,0,0,$month, $day, $year));
	$next_day['day'] = date('j', $next_day['timestamp']);
	$next_day['month'] = date('n', $next_day['timestamp']);
	$next_day['year'] = date('Y', $next_day['timestamp']);
	
	$navigation['next'] = $module->CreateLink($id, 'default', $returnid, '', array('year'=>$next_day['year'], 'month'=>$next_day['month'], 'day'=>$next_day['day']), '', true, true, '', false );
	$navigation['prev'] = $module->CreateLink($id, 'default', $returnid, '', array('year'=>$prev_day['year'], 'month'=>$prev_day['month'], 'day'=>$prev_day['day']), '', true, true, '', false );
} else {
	$navigation['next'] = $module->CreateLink($id, 'default', $returnid, '', array('year'=>$next_month['year'], 'month'=>$next_month['month']), '', true, true, '', false );
	$navigation['prev'] = $module->CreateLink($id, 'default', $returnid, '', array('year'=>$prev_month['year'], 'month'=>$prev_month['month']), '', true, true, '', false );
}
What this code does:
If $day is set (meaning it's listing events for a certain day) it will calculate the date (day, month and year) for the next and previous day. These values are then used to create the navigation links.
Else, if $day is not set (meaning it's listing events for a certain month) it will create links for the next/previous months.


FYI, I'm using Calendar 0.8.2

Hope it helps!

PS. If anyone finds a way to navigate to the next and previous event I would like to hear about it!!