Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.x-dev
Component:
node data
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
1 Jul 2008 at 16:03 UTC
Updated:
17 Mar 2010 at 18:58 UTC
I have a list of stories which I want to group by year, but there doesn't seem to be a fine enough filter in Views to do so; I can only choose the Date field, not a sub-value from there. I see there is a 'Group by Month' module, but it's for 5.x only; is there a way to perform a similar function in Views?
Comments
Comment #1
merlinofchaos commentedAssuming you're talking about post date or a similar field, go to configure that field. Set "date format" to Custom and set the Custom format to Y
Then set that to your grouping field. You probably also should sort on this field and set the granularity to Year to make sure items appear in the right order.
Comment #2
stopsatgreen commentedGot it! Thanks a lot. Quick follow-up: is there any way of declaring the Grouped value? That is, in my News page to have the year appear above the group like so:
2008
- Story
- Story
2007
- Story
- Story
I can't see anything obvious that would allow me to do that.
Comment #3
merlinofchaos commentedI don't understand the question; it seems like what you already have should do that? What am I missing?
Comment #4
stopsatgreen commentedAt the moment the grouping takes place, but I want to know if it's possible to output the grouping criteria as a title; for example, as I'm grouping by year, would it be possible to state the year as a subtitle before each group:
2008
- Story
- Story
2007
- Story
- Story
Comment #5
merlinofchaos commentedThat should be happening pretty much automatically if you have grouping set up. The list template specifically prints the $title, which is the grouping field.
Comment #6
stopsatgreen commentedHmmm... no, unless I've modded a template and not realised:
http://tinyurl.com/6k2nwf
Comment #7
stopsatgreen commentedI still can't see a way to put the Group criteria as a title; please see my page for an example of what I mean:
http://217.206.162.200/drupal/?q=latest-news
The news is grouped by year, but I want the year to appear as a title above each group. Is this possible?
Comment #8
merlinofchaos commentedIn all templates that support grouping, there is a $title variable that is printed. That is the grouping field for that group of templates. This has been verified as functional, so I dunno what it is that's causing this not to work for you.
Comment #9
stopsatgreen commentedRather stupidly, I'd overwritten the template in the theme directory and removed the if... print statement which output the title. I did this very early in the build and forgot about it.
Thanks for your patience in helping me track this down.
Comment #10
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #11
idmacdonald commentedHi,
I am reopening this one, because I want to group a list of events by month. I can see the custom display format as an option for a post date, but I am looking to group a list of events by month. I don't see any custom date format options for displaying 'date' module fields.
I supposed it may be a 'date' module issue to allow custom display formats, but if that's not available at the moment, then I guess I need to figure out how to theme the view.
Comment #12
esmerel commentedDon't reopen issues that have been closed for nearly a year. Open a new one, and refer to the old one.