I have a news system using views that works with a contextual filter by year to make a news archive. The views for the archive page looks like this:

FIELDS
Title
Post Date

CONTEXTUAL FILTERS
Content: Created Year (display a summary)

So the views will output a list of years, and when I click on a year, a list of news items from that year are shown.
I've tried to input this into my menu as well with Menu_Views to create something like:
News Archive
- 2012
- 2011
- ....

But it doesn't display anything. When I completely remove the contextual filter, it does work (but just displays all the search results in my menu of course)

Anyone else ran into this problem? Any idea what might be the cause of this?

Comments

markhalliwell’s picture

Category: bug » support
Status: Active » Closed (works as designed)

This problem is related to view configuration and not a bug in this module. The view should be configured to use a default value if no argument is provided. If you wish to hide the view when no argument is present, you must use the arguments field in the menu views item configuration. These arguments are passed on to the contextual filters.

Jones03’s picture

Status: Closed (works as designed) » Active

Thanks for your quick feedback Mark, and great work with the module btw! :).

The view should be configured to use a default value if no argument is provided.

Yes, there are a couple of options when the argument is not in the URL, here is what I configured:

Configure contextual filter: Content: Created year

WHEN THE FILTER VALUE IS NOT IN THE URL
-> Display a summary

So I chose to display a summary which exactly what I want. The summary will display all the years as links for which there is content. Which looks like this in my case:
2012 (points to /news/archive/2012)
2011 (points to /news/archive/2011)

These 2 links are what I want to have displayed in my menu by using menu views, but it doesn't work. I've tried the argument field as you suggested, but it would just display all the content for a certain year in my menu.

Any thoughts on how to get this to work? Is it supported by the module, or am I still making a mistake in my views?

markhalliwell’s picture

Title: Does not work with contextual filters » Not working with empty arguments and default contextual filter functionality
Component: User interface » Code
Assigned: Unassigned » markhalliwell
Category: support » bug
Status: Active » Fixed

Alright, I took a look into this a little bit further. I retract my earlier statement and will admit this is a very interesting bug, sorry to dismiss it so quickly. I typically look at the user's join date to determine validity in "bug" reports, as often there is just confusion in how Drupal works.

What was happening was that the empty arguments in the menu view configuration was still providing an "empty string" as an argument. Thus views that the view was being provided by an argument. I put in some logic that converts empty argument values into NULL: http://drupalcode.org/project/menu_views.git/commit/b60f7a2

This will be in the next 7.x-2.x-dev release. Let me know if this fixes your issue, I was able to create a default summary display just fine after this.

Jones03’s picture

Tested with the latest dev and works like a charm now. Thanks Mark, keep up the nice work! :)

markhalliwell’s picture

Glad this fixed your issue!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.