Greetings all,
I am new to Drupal and have watched a bunch of great tutorials on using Views and the Calendar Module. I am totally excited about getting familiar with Drupal and the functionality that it provides, but this one issues with the Views and the Calendar Module is driving me crazy!!!
When I create an Events Calendar using views, the Calendar Header in the Month and Block View display:
Friday, August 1, 2014 (Month View)
Friday, August 1 (Block View).
I would like the header in both of these Views to display "August 2014".
I have tried going through all of the options on the Views page, and I can't find anything that works. I've tried changing settings, modifying the date settings, adding a new date setting under administration. I've even looked at some of the code in the Calendar module setting, and I can't seem to find anything to help me.
Is there anyway to change the Calendar header to make it appear "August 2014" instead of "Friday, August 1"?
Thank you so much for your help in advance. This is driving me crazy.
Comments
You're not crazy - that's
You're not crazy - that's kind of hard to get at.
Looks like that title string (as well as the prev and next buttons) is provided by the Date module, in a theme template called date-views-pager.tpl.php, which is found in /sites/all/modules/date/date_views/theme.
The template in turn uses a variable called $nav_title, which is set in a preprocess function in /sites/all/modules/date/date_views/theme/theme.inc.
You could go find that stuff in the date module and override it in your theme, but it doesn't look as if there's anything you can do from the admin interface.
Maybe easier to just whack it into shape in Javascript.
============================
Resonetrics: Better Tools for Building Brands
http://resonetrics.com
http://technologyformarketers.com
http://kittenassociates.org
http://www.linkedin.com/in/sammooreatresonetrics
Thank You!
Based on your advice, I was able to find the offending code. Not really knowing what I was looking at, I searched the code, and it turns out that there was a problem with this file: /sites/all/modules/date/date_views/theme/theme.inc.
I found a solution on this thread https://www.drupal.org/node/2294973 and it worked like a charm.
From micahw156:
"Quick workaround for people unable to apply the patch:
STEP 1: Edit date_views/theme/theme.inc and go find line 165.
Change these two lines:
To these two lines:
Note: the only difference is one underscore character added to each line.
Upload the changed file back to your web server.
STEP 2: Go to (YOUR_WEBSITE)/admin/config/regional/date-time/date-views and click Save. If you get permissions errors, try clearing caches."
Thank you, Sam. Based on your advice...my issue is now solved.
Cool beans.
Cool beans.
Keep in mind that if you modified the Date module's components you'll have to re-apply your changes on the next update of Date (unless the maintainers commit the change into the codebase).
============================
Resonetrics: Better Tools for Building Brands
http://resonetrics.com
http://technologyformarketers.com
http://kittenassociates.org
http://www.linkedin.com/in/sammooreatresonetrics
No need to change in core files
You can overwrite the function in template.php with below code.
Make changes inside the function according to your requirement
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;
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;
}
}
Thanks - this template.php
Thanks - this template.php solution works great.
Brian Gilday
Municode
www.municode.com
Thanks
Thanks this answer works for me. thanks again.
Thanks
Putting this modified code of theme_date_nav_title($params) in our module and using our theme name worked for us.
Thank you very much.
I am also struggling with
I am also struggling with this issue. I am not much of a programmer. I am attempting to upgrade a very simple community site from Drupal 5 to Drupal 7, while keeping the look substantially the same. So this is a fresh install with all the latest up-to-date versions downloaded this week. I am using Garland theme, and the Calendar Block header of Weekday-Month-Day is too wide for the block in the sidebar. I think Month alone would be sufficient, but anything shorter or at least a smaller font would work better!
So to apply the above template modification (instead of a modification to the date code), I need to modify the ./themes/garland/template.php file, correct?
The first line:
should this be re-written from "Yourthemename_date_nav_title" to "Garland_date_nav_title"?
To eliminate all but the Month from the title header, is that done here:
by changing "$date_arg = $date_info->year .'-'. date_pad($date_info->month);" into
$date_arg = $date_info->month;"?
or do I need to change something down here:
I'm not sure what -- maybe "View full page month" to some other pre-defined string?
Nice post!
Nice post!
Thanks! This worked perfectly
Thanks! This worked perfectly.
I did change weeks value from:
'F j Y' : 'F j'
to
'F j, Y' : 'F j'
So it displayed as:
Week of January 2, 2015
thanks mate, worked perfectly
thanks mate, worked perfectly
Thanks so much!
This was a big help. Worked great!
Thanks - worked for me too.
Great code snippet - https://www.drupal.org/node/2315511#comment-9031059 works for me too in template.php
Thank you so very much. I'v
Thank you so very much. I'v spend almost two days fighting this beast, only to solve the whole problem with two underscores...
thank you
Worked perfectly with misterbrigham's advice! Quick'n'dirty, yeah!
worked fine!
Thanks, I was getting mad with this issue!
Thanks!!
Thank you very much!! You solved my issue!
Thank you!
Thank you!
That worked for me.
NOTE: Before the modifications on /sites/all/modules/date/date_views/theme/theme.inc, the settings on (YOUR_WEBSITE)/admin/config/regional/date-time/date-views were not displayed. After the modifications it works like a charm.
thanks
Thanks for your post here. adding the _format_with_year was the key to repairing this!!
Doesn't work for me
I tried adding that to my template page and it didn't do anything. Could it have something to do that we are using Date as a field for Events and Meetings and not the Date Content type itself (I don't now if that makes any sense?)?
One would think that this would be something standard for configuring in the View!
- delete pls
- delete my entry here pls
Doesn't work for me too :-(
Doesn't work for me, the title stay same format!
First solution worked for me
Adding the two underscores in /sites/all/modules/date/date_views/theme/theme.inc as suggested in MisterBrigham's response, above worked perfectly. The mini-calendar now displays the month alone and fits nicely in the sidebar. I still have not been successful figuring out how to properly modify the template.php file however.
Check the name of the function and clear all caches
If your are implementing remyarose's solution check that the name of the function matches function YOURTHEMENAME_date_nav_title and clear all caches at /admin/config/development/performance. It worked for me.
Worked
This is amazing patch.
like a charm
hi guys, thx a lot for helping me! searched for the proper thread about half an hour, solved the problem with your help in one minute :-)
regards karl
politiktraining.at | politiktraining.net
Thanks remyarose !
This worked wonders for me. thank you very much remyarose
I was able to fix this with a
With the Date module version 7.x-2.8 I was able to fix this with a drush command to set the variable:
drush vset date_views_monthformat_with_year "F Y"The date_views module doesn't actually set that variable, so it uses a default PHP date string value of "l, F j, Y". Setting the variable via drush simply overrides that without having to edit any code.
possible typo?
@joe.corall, Did you mean:
drush vset date_views_month_format_with_year "F Y"?This was a great suggestion, but didn't work for me. The above variable was already set to "F Y" out of the box.
Also, I found a place where date_view does seem to save these variables: /admin/config/regional/date-time/date-views
Update: solution found in this issue thread
For any others coming behind me, the patches and updated dev releases in this issue queue ultimately resolved the date display issue for me.
No.
No.
I thought the missing "_" was odd, too. The string was from the date module's file
date_views/theme/theme.inc:http://d.pr/i/10ane
I updated my comment with the version of the date module I'm on - 7.x-2.8.
Thanks!
Joe
This is in UI, see /admin
This is in UI, see /admin/config/regional/date-time/date-views page settings.
@azovsky How does /admin
@azovsky How does /admin/config/regional/date-time/date-views work? I want to change the header for the month view, so it doesn't display the date. (i.e. April 2013 instead of Monday 13 April 2014).
This won't work because of
This won't work because of the missing "_" as stated by @joe.corall. The date_views module (inside of date module) has the following logic in
theme_date_nav_title:As a result the variables being retrieved are
date_views_monthformat_with_yearanddate_views_monthformat_without_year. So if you set the variable without the underscore between month and format, it will work.If the module is "fixed" to have underscores which would in term allow you to use the UI settings at admin/config/regional/date-time/date-views...but I don't know if this was intentional and/or being used elsewhere.
The answer from the template
The answer from the template preprocess works perfect! Thanks!
If Date part of distribution uploading latest dev version works
FYI - I have a site using a distribution and Date is part of the distribution modules. The only fix that worked was installing the latest dev version in the profile (after the deleting the existing Date folder and the running db updates). I have other sites where Date is in the standard /sites/all/modules and the patch or the drush entry work fine.