Hi Calendar-fans,

I'd like to link to the month view (instead of the day-view) when I click on a day of the mini calendar.

I think something needs to be changed on calendar-datebox.tpl.php.

Any suggestions?

Comments

quotientix’s picture

Status: Active » Closed (fixed)

Here's how I got it to work:

  • Copy the calendar-datebox.tpl-php to your theme-template directory
  • Replace the code of the file with the following code, clear the site-cache afterwards
if(!empty($selected) && !empty($url)){
	// calendar settings
	$calendar = $view->style_plugin->date_info;

	// build url to overview
	$overview_url = $calendar->url;

	$overview_url = explode('/', $overview_url);
	unset($overview_url[count($overview_url)-1]);
	$overview_url[] = $calendar->date_arg;
	$overview_url = implode('/',$overview_url);
	
	// build query param for calendar block
	$query = $_GET;
	unset($query['q']);
	
	$date_formatted = t(date('F', strtotime($date))) . ' ' . t(date('Y', strtotime($date)));
	$day = l($day, $overview_url, array('query' => $query, 'attributes' => array('title' => t('Show all dates on') . ' ' . $date_formatted, 'class' => array('day-link'))));
}
<div class="<?php print $granularity ?> <?php print $class; ?>"><?php print $day; ?></div>

Hope that helps, if someone happens to have the same issue.

Xilis’s picture

I solved this by using template_preprocess_calendar_datebox by adding the code below into a custom module. I don't use the day/week/upcoming display so I have them disabled.

function MODULENAME_preprocess_calendar_datebox(&$vars) {
  $date = $vars['date'];
  $month_path = calendar_granularity_path($vars['view'], 'month');
  if ($vars['mini']) {
    if (!empty($vars['selected'])) {
      $vars['url'] = $month_path . '/' . substr($date, 0, strrpos($date, "-"));
      $vars['class'] = 'mini-day-on';
      $date_formatted = t(date('F', strtotime($date))) . ' ' . t(date('Y', strtotime($date)));
      $vars['link'] = l($vars['day'], $vars['url'], array('attributes' => array('title' => t('Show all appraisals on') . ' ' . $date_formatted, 'class' => array('day-link'), 'target' => '_blank')));
    }
  }
}
crutch’s picture

Thanks Xilis this works great although I think it should be

function THEMENAME_preprocess_calendar_datebox(&$vars)