N
N
NataliaCh2015-07-27 18:12:19
Drupal
NataliaCh, 2015-07-27 18:12:19

How to correctly display the name of the month in the Calendar module?

Drupal 7, Calendar 3.5 module, Date 2.8 module.
Year tab. In addition to the name of the month, the name of the first day of the week of the month is also displayed:
Thursday, January 1 instead of January
Sunday, February 1 instead of February
Sunday, March 1 instead of March
Has anyone come across? How to fight?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
archelon, 2015-07-28
@NataliaCh

came across just a few days ago.
I don’t remember where I found it, I copy it from my topic.
add the following code to the template.php file (instead of mytheme - the name of your theme):

function MYYTHEME_date_nav_title($params) {
  $granularity = $params['granularity'];
  $view = $params['view'];
  $date_info = $view->date_info;
  $link = !empty($params['link']) ? $params['link'] : FALSE;
  $format = !empty($params['format']) ? $params['format'] : NULL;
  switch ($granularity) {
    case 'year':
      $title = $date_info->year;
      $date_arg = $date_info->year;
      break;
    case 'month':
      $format = !empty($format) ? $format : (empty($date_info->mini) ? 'F Y' : 'F Y');
      $title = date_format_date($date_info->min_date, 'custom', $format);
      $date_arg = $date_info->year .'-'. date_pad($date_info->month);
      break;
    case 'day':
      $format = !empty($format) ? $format : (empty($date_info->mini) ? 'l, F j Y' : 'l, F j');
      $title = date_format_date($date_info->min_date, 'custom', $format);
      $date_arg = $date_info->year .'-'. date_pad($date_info->month) .'-'. date_pad($date_info->day);
      break;
    case 'week':
        $format = !empty($format) ? $format : (empty($date_info->mini) ? 'F j Y' : 'F j');
      $title = t('Week of @date', array('@date' => date_format_date($date_info->min_date, 'custom', $format)));
        $date_arg = $date_info->year .'-W'. date_pad($date_info->week);
        break;
  }
  if (!empty($date_info->mini) || $link) {
      // Month navigation titles are used as links in the mini view.
    $attributes = array('title' => t('View full page month'));
      $url = date_pager_url($view, $granularity, $date_arg, TRUE);
    return l($title, $url, array('attributes' => $attributes));
  }
  else {
    return $title;
  }  
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question