I installed the calendar module and enabled the Calendar view. The Calendar block is just what I need, except, I only want the dates to be links if there is content for that day. Right now, every date is a link, and it's misleading. Anyone know how to do that?

Thanks,
Blue

Comments

chrsnlsn’s picture

Have to modify
function _preprocess_calendar_datebox(&$vars)
Place the function in your template.php or custom module and do something like the following some of the fields may need to be changed depending on the results of your view and the fields you use, also you will want to change the url to point to your own events section. Hope this helps someone find the way.

function _preprocess_calendar_datebox(&$vars) {
 
  $date = $vars['date'];
  $view = $vars['view'];
  $now = time();
  $datetimestamp = strtotime($date);
  $vars['day'] = intval(substr($date, 8, 2));
  $force_view_url = !empty($view->date_info->block) ? TRUE : FALSE;

  if ($view->date_info->mini) {
    if (!empty($vars['selected']) && ($datetimestamp>$now)) {
	  foreach($view->result as $key => $value){
		    $startdate = date('Y-m-d',strtotime($view->result[$key]->raw->node_data_field_event_date_field_event_date_value));
			$enddate =   date('Y-m-d',strtotime($view->result[$key]->raw->node_data_field_event_date_field_event_date_value2));

		if(($date >= $startdate) && ($date <= $enddate)){
		$vars['url'] = 'upcoming-events/details/'.$view->result[$key]->raw->nid;
		$vars['class'] = 'mini-day-on';
		$vars['link'] = l($vars['day'], $vars['url']);
		break;
		}
		}
      
	  $vars['granularity'] = $view->date_info->granularity;
	  $vars['mini'] = $view->date_info->mini;
    }
    else {
      $vars['class'] = 'mini-day-off';
      $vars['link'] = $vars['day'];
    }
  }
  else {
    $vars['class'] = 'day';
  }

}

web Kreator