I can't find this, it seems to be standard, but I probably switched it off lately.

See screenshot.

calendar.jpg23.06 KBwebsmash


websmash’s picture

No one?

websmash’s picture

Anyone can help me out?

eusonic’s picture

Title: How to get the year in the mont view date heading? » How can I show the year in the title of a mini calendar block?
Version: 7.x-3.3 » 7.x-3.x-dev

I have the same question, and I'm disappointed that this has gone unanswered for 4 months.

To clarify, I need to add the year to the title of a mini calendar block, which normally only shows the month. Is there a simple way to override the default titles for calendar blocks?


kfurlotte’s picture

I have the same exact problem right now. I feel like it's something intuitive and easy to do, but for some reason, I can't figure it out.

ThomWilhelm’s picture

Have just come across the exact same problem as eusonic mentioned, when viewing by month with the mini calendar it makes sense to show the year as once you toggle between December/January, it makes sense to make clear to the end user which year they are now viewing. Am having a look around to see if there's an easy way to do this, if anyone finds a way then please let us know.


UPDATE: I ended up using https://drupal.org/project/pretty_calendar as it did this out of the box.

aidoskz’s picture

try to insert this into template.php

function yourthemename_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;
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);
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);
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;

whmedia’s picture

#6 works perfectly thanks!!!

thalemn’s picture

Thank you for posting the template.php code. Worked perfectly.

alexaffonso’s picture

Issue summary: View changes

#6 works well, but...

I can't figure out how to place the month and year within different divs/ tags. I'd like to be able to format the month and year as two different elements, but the #6 solution inserts the year inside the same h3 and a tags of the month. Do someone know how to achieve that? I tried the date-views-pager.tpl.php with no success.

Right now I'm with the following results:

<div class="date-heading">
      <h3><a href="http://mysite_url/calendar-node-field-data/month/2014-05" title="Ver página completa do mês">maio 2014</a></h3>

And I'd like to have something like this:

<div class="date-heading">
      <h3><a href="http://mysite_url/calendar-node-field-data/month/2014-05" title="Ver página completa do mês">maio</a></h3>

I do appreciate any help.

kamida’s picture

One way of doing it would be to remove #6 from your template.tpl.php file (the whole function) and put this instead:

function yourtheme_preprocess_date_views_pager(&$vars){
	$date_info = $vars['plugin']->view->date_info;
	$vars['year'] = $date_info->year;
	$vars['granularity'] = $date_info->granularity;

This gives you access to the year and granularity in date-views-pager.tpl.php.
To have it output your desired markup for month mini-calendars, you would then edit it as follows:

<div class="date-heading">
	<h3><?php print $nav_title ?></h3>


<div class="date-heading">
	<h3><?php print $nav_title ?></h3>
	<?php if($mini && $granularity == 'month'): ?>
	<h2><?php print $year ?></h2>
	<?php endif; ?>
alexaffonso’s picture

#10 worked like a charm.

Thank you so much @kamida. I wouldn't come up with such solution. I do need to dive deep into PHP.

kamida’s picture

Some php skills, however small, do help tons. Especially when tracking down which file/function/variable does what can be such a pain. Glad I could be of help :)

Funksmaname’s picture

I really need to do this in d6... any ideas?

The 'date-views-pager.tpl.php' is 'date-navigation.tpl.php' in Drupal 6. I tried the above, also tried chanigng the function to yourtheme_preprocess_date_navigation but that didn't work...
Any help much appreciated!

Funksmaname’s picture

For anyone interested - the correct preprocess function for drupal 6 is:

function yourtheme_preprocess_date_navigation(&$vars){
$date_info = $vars['view']->date_info;
$vars['year'] = $date_info->year;
$vars['granularity'] = $date_info->granularity;
heshanlk’s picture

What you need to do is this:

function vportal_preprocess_date_views_pager(&$vars) {
  $vars['nav_title'] = YOUR NEW TITLE WITH LINK;
metakel’s picture

Just add the code below to the template.php of your theme. Create a new one with


at the beginning if it does not exist yet. Replace nameofyourthem with the actual theme name and clear theme-registry:

function nameofyourtheme_date_nav_title($params) {
$params['format'] = ($params['granularity']=='month') ? 'F Y' : $params['format'];
$output = theme_date_nav_title($params);
 return $output;
Bartelli’s picture

The code in #16 works nicely. Clean and simple.

roball’s picture

Solution #16 also worked perfectly for me. Here is a slightly simplified code:

function MYTHEME_date_nav_title($variables) {
  if ($variables['granularity'] == 'month') {
    $variables['format'] = 'F Y';
  return theme_date_nav_title($variables);
roball’s picture

Title: How can I show the year in the title of a mini calendar block? » How to add the year to the month in the title of a mini calendar block
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

achu aji’s picture

#6 worked for me. Thanks for the patch.