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
Comment #1
markhalliwellThis 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.
Comment #2
Jones03 commentedThanks for your quick feedback Mark, and great work with the module btw! :).
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?
Comment #3
markhalliwellAlright, 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/b60f7a2This 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.
Comment #4
Jones03 commentedTested with the latest dev and works like a charm now. Thanks Mark, keep up the nice work! :)
Comment #5
markhalliwellGlad this fixed your issue!