I'm trying to set up a calendar so that the title changes depending on whether you've clicked on the month view or the day view, so I can have it say something like "Events Calendar: Month at a glance" vs. "Events Calendar: Day at a glance". It looks like setting the view title to override in the Month view or Day view should do this, but it just doesn't seem to work. It either inherits the default title or the page title (that the month and day views are attached to) or has no title at all if there aren't any default titles or page titles. Does anyone have any suggestions for making this work?

Thanks in advance!

Comments

deggertsen’s picture

Does this happen to be at all related to this issue? #565494: Can't Disable Event Title Links

It seems that the title field is very difficult to change...

biz123’s picture

Component: Miscellaneous » User interface

Thanks for asking Deggertsen. My issue does not involve event titles. I'm trying to change the calendar view title based on whether it is a day view or month view of the calendar page. I still haven't had any luck. I am using the latest dev modules for calendar, views, event and date but it just doesn't seem to work properly.

donquixote’s picture

Same problem here.
The way I understand it, you should be able to change the view title in the "Calendar page" display, by putting something like "%1" in the Title field of the date argument. Unfortunately, I always get a month title, such as "December 2010", even for day and year view.

Btw, my date fields are "datestamp". I don't know if that makes any difference.

WiredEscape’s picture

Category: support » bug

Have same problem. Setting view titles individually and using overridden values but uses page view title for each view.
D6.16
Views 6x-2.10
Calendar 6.x-2.2

Kristen Pol’s picture

Subscribing... I also just get month & year using %1 in the title no matter what view I am in.

Kristen

robinmcg’s picture

Subscribe

ManchesterNewsGuild’s picture

Subscribing

siva.thanush’s picture

Issue summary: View changes

Is there any way to do this.
I hope the views coming from the core can be edited to override the title of the calendar title.
The week view is displaying the title as "Week of .."
I want to change it as Week's start date to End date.

Anyone knows how to do this please help.

Thank you,
Regards,

Siva

choster’s picture

nvl.sateesh’s picture

It seems an old post, but I found it just now. Just in case it helps someone.

The view title for calendar pages is actually coming from the theme.inc from date module's date_views: "modules/date/date_views/theme"

You can override it by copying the function theme_date_nav_title($params) into your template.php file and rename it to your theme name. Such as MYTHEME_date_nav_title($params){}

You can change any view's title the way you want from here.

In a nutshell, place the following code in your template.php file, change the MYTHEME to your theme name and alter the actual logic as you want.

/**
 * Theme the calendar title
 */
function MYTHEME_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;
  $format_with_year = variable_get('date_views_' . $granularity . 'format_with_year', 'l, F j, Y');
  $format_without_year = variable_get('date_views_' . $granularity . 'format_without_year', 'l, F j');
  switch ($granularity) {
    case 'year':
      $title = $date_info->year;
      $date_arg = $date_info->year;
      break;
    case 'month':
      $format = !empty($format) ? $format : (empty($date_info->mini) ? $format_with_year : $format_without_year);
      $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) ? $format_with_year : $format_without_year);
      $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) ? $format_with_year : $format_without_year);
      $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;
  }
}
humansky’s picture

The code in comment #10 worked for me, except I had to change the following two lines:

$format_with_year = variable_get('date_views_' . $granularity . 'format_with_year', 'l, F j, Y');
$format_without_year = variable_get('date_views_' . $granularity . 'format_without_year', 'l, F j');

To this:

$format_with_year = variable_get('date_views_' . $granularity . '_format_with_year', 'l, F j, Y');
$format_without_year = variable_get('date_views_' . $granularity . _'format_without_year', 'l, F j');

And it worked for me using the default formats provided.

kopeboy’s picture

Title: Can't Override Calendar title in month or day view » Calendar title is always in day format
Version: 6.x-2.x-dev » 7.x-3.5

Indeed that is a bug! please fix

Even if the calendar type is set for example to "Month", the header of the calendar is now "Monday, 1 June, 2015".

After the fix, it will be "June 2015".

The correct code is

$format_with_year = variable_get('date_views_' . $granularity . '_format_with_year', 'l, F j, Y');
$format_without_year = variable_get('date_views_' . $granularity . '_format_without_year', 'l, F j');

(@humansky code had a typo too, the _ must be inside the ' ' in both lines)

cmseasy’s picture

Bumped into this issue, solved it with #10 and #12.
A better place to solve this is with a patch for the calendar module.

Michael_Lessard_micles.biz’s picture

Personally, I had to apply the corrected lines from #12 also under the default function theme_date_nav_title($params) {

otherwise my month default title remained "day, month 1, year" (Saturday, August 1, 2015).

One also needs to re-save the settings at: admin/config/regional/date-time/date-views

See :
https://www.drupal.org/files/issues/date-title_date_formats-2294973-70.p...
From
https://www.drupal.org/node/2294973#comment-9417959

nasi’s picture

I thought it might be using the 'Date views day format with year' settings in Regional settings, rather than the Month views setting, as that defaults to l, F j, Y - but that's not it; changing those settings makes no difference. I, F j, Y seems to be hard wired into the module.

So does seem to be an outstanding bug that needs fixing…

nasi’s picture

RAWDESK’s picture

#14 resolved my issue too.
Hence, dpm placed in my copied theme function inside template.php is not shown. So the copied function is not being called at all.

apaderno’s picture

Version: 7.x-3.5 » 7.x-3.x-dev