I'm using the date_browser view to create monthly archive pages. Obviously, I have the Granularity set to "Month" in my date argument. Everything works great, except in the summary, the month and year are separated by a comma. Example:
* November, 2010 (2)
* October, 2010 (2)
* September, 2010 (2)
* July, 2010 (3)
* June, 2010 (3)
* May, 2010 (1)
* April, 2010 (1)
* March, 2010 (4)
* February, 2010 (1)
* January, 2010 (1)
My client wants to remove the comma from the summary, but I cannot for the life of me figure out how. Help?
Comments
Comment #1
gradynoonen commentedComment #2
casaswing commentedDid you find the answer? Love to know how.
Comment #3
xjmI'm seeing the comma with date arguments in two places: view titles and the summary view. I'm using the node posted date as my date arg.
It appears to be derived from the site long date format. You can actually get rid of the comma fairly easily by changing your long date format at
http://example.com/admin/settings/date-time/formats. Steps:http://example.com/admin/settings/date-time/formats/add.l F j Y - H:i a(This will display a date like "Sunday August 29 2010 - 6:16 pm." See php.net/date for more information and formatting options.)
http://example.com/admin/settings/date-time/formats. Under Long date format, select your new, comma-less format and click Save configuration.That's all you need to do. All (?) your Views dates should now render "Month Year" according to the format you defined, without the comma. Mine did, at least, in my month-granularity summary block and my monthly archive page titles.
The only disadvantage of this is that it alters the long date format everywhere it is used on your site. So, it's still a reasonable feature request to add a control for this on the date argument settings form. One could either allow the user to select the core date format to use (which would allow people to choose any format they wanted since core allows adding any number of date formats), or perhaps a
date()-style text field (where one could enter a formatter string like "Y m").The form would need to be altered in (I think?)
handlers/views_handler_argument_date.inc, and then that would need to be supported in... somewhere. At first I thoughtmodules/node/views_handler_argument_dates_various.inc, but I'm actually a bit mystified as to why the long date format is getting used, because it's not in that file anywhere that I can see. Anyone have a lead on this?Comment #4
xjmComment #5
xjmAlright. I got a little reckless, hacked up core, and overrode
format_date()to return "foo". No effect on the rendering of the views arguments, though it affected dates in individual nodes for sure. So, they're not being rendered byformat_date().Perhaps manually fetching the long date format somehow? I grepped 'date_format_long' in the views dir, but the only occurrence was in the profile field handler, which I confirmed through merciless hacking does not get included. (I have profile.module disabled anyway.)
I also tried disabling date.module, ctools, context, and every views-extending module I had; the behavior was unchanged. I inspected the view object to verify it included the custom formats listed in
views_handler_argument_dates_various.inc. It did, and no trace of the long date format. I even changed the reference to date_format_long insystem.module, no effect. In all cases the view title had a comma if my site long date format had a comma, and did not if it did not.I'm really confused.
Comment #6
xjmThe query being run is:
Nothing about the comma in there.
Comment #7
magnestyuk commentedI can also confirm that the summary view gets the long date format. I'm using the latest dev release, but it is the same with the latest stable as well.
Comment #8
TimeBandit commentedJQuery:
$(".view-archive a").each(function() {
$(this).text($(this).text().replace(",",""));
});
Comment #9
Katrina B commentedHere's how our lead developer fixed the problem:
(1) Override views-view-summary-unformatted.tpl.php to views-view--archive.tpl.php in your active theme directory.
(2) Inside the foreach loop
<?php foreach ($rows as $id => $row): ?>in that template, add
<?php $row->link = str_replace(',', ' ', $row->link); ?>.(3) Flush site cache.
Hope this helps!
Comment #10
damienmckennaUnfortunately the Drupal 6 version of the Date module is no longer supported. That said, we appreciate that you took time to work on this issue. Should this request still be relevant for Drupal 7 please feel free to reopen it. Thank you.