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

gradynoonen’s picture

Status: Active » Closed (fixed)
casaswing’s picture

Did you find the answer? Love to know how.

xjm’s picture

Version: 6.x-2.4 » 6.x-2.x-dev
Category: support » feature
Status: Closed (fixed) » Active

I'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:

  1. Go to http://example.com/admin/settings/date-time/formats/add.
  2. Create a date format that does not have a comma between month and year, e.g.:
    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.)
  3. Click Save configuration.
  4. Now, go to 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 thought modules/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?

xjm’s picture

Title: Date Browser View Summary Format » Commas in date summary views
xjm’s picture

Alright. 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 by format_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 in system.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.

xjm’s picture

The query being run is:


SELECT node.nid AS nid,
   DATE_FORMAT((FROM_UNIXTIME(node.created) + INTERVAL -18000 SECOND), '%Y%m%d%H%i') AS node_created_minute
 FROM node node 
 WHERE ((node.type in ('announcement')) AND (node.status <> 0))
    AND ((DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(node.created), 'UTC', 'America/Chicago'), '%Y-%m') <= '2010-02' AND DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(node.created), 'UTC', 'America/Chicago'), '%Y-%m') >= '2010-02'))
   ORDER BY node_created_minute DESC

Nothing about the comma in there.

magnestyuk’s picture

I 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.

TimeBandit’s picture

JQuery:
$(".view-archive a").each(function() {
$(this).text($(this).text().replace(",",""));
});

Katrina B’s picture

Here'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!

damienmckenna’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Unfortunately 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.