0

I would like to make a grouping of articles based on the year and month. In other words something like

  • April, 2013
  • March, 2013
  • February, 2013
  • January, 2013

Each would be a link to the articles section and provide a contextual filter (/articles/2013/1 for January 2013).

I've tried playing with the views module to create this view. I selected only the posted date and then formatted it to show only the Month and Year. Then I turned on aggregation to group the results together, but it appears aggregation is using the entire date (including the day). I also tried grouping by the posted date in the table settings but there doesn't appear to be a way to rewrite the results of the group header.

Is there a way to do this with views or some other module?

1 Answer 1

0

I have personally done the contextual filter part of it and can confirm it works very well and is easy to setup.

Simply add a contextual filter for "Content: Created year" and "Content: Created month" and then set the Path of the view to "/articles". I use basic validation for the contextual filters and have also setup something for no results so the users aren't presented with a blank page.

I'm not quite sure what you're asking for with the other part of the question.

I think the easiest way of going about this is to create a separate Views block and add a field that contains the post date. You can then use a custom Date format to display the post dates the way you want them. "F, Y" should do it.

Turn on Aggregation and make sure it's grouping the results together and you should be good to go. You can now use the rewrite as link to accomplish what you need. You may need to add a couple of other hidden fields to get all the parameters you need.

UPDATE: I realized there is a problem here. Views aggregation works on the raw SQL data only which is what I think your original problem was. This means that group by date doesn't actually work as you mentioned earlier. There are a couple solutions I came across http://drupal.org/node/388140, http://drupal.org/project/views_date_format_sql, and http://groups.drupal.org/node/40356.

1
  • Thanks for the suggestions. Unfortunately, none of these are working. I installed the views format sql module and even after checking the box to use SQL for date formatting, my view still won't group by month and year. I also don't want to display all the articles, only the month and year so that I can create a contextual filter from the results.
    – Robbert
    Commented Apr 5, 2013 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.