You, like me, probably recognize the following scenario from client projects:
- The client wants to display sidebar content on the site.
- The client wants different sidebar content to be displayed on different sections on the site.
- The client wants to be able to show sidebar content in several different sections at the same time, without having to duplicate the content or change settings on more than one place.
- The client doesn't know which sections the site will have, or wants to be able to change the sections every once in a while.
The first two or maybe three cases can be managed pretty well with modules like Context, Rules, Panels – and sometimes even standard blocks. But when combined with the last case, you either have to let the client mess around with the settings you stored so neatly with Features (not to mention train the client in using the modules mentioned above), or you'll have to build a special-case module that allows the settings that are relevant for this client. Neither are very fun, and they are both bound to fail in the long run.
That is exactly why the Views Menu Support was written. Saying that it will take care of all possible problems might be saying too much, but it will definately solve the four cases above – and in a way that integrates right off with standard Drupal frameworks.
In brief, the module does the following:
- It provides a widget for populating integer fields with menu item IDs. Using this widget, you can select "front page" or "sports" or whatever menu items you got on your site.
- It provides a filter handler to Views, allowing you to filter out content where an integer field matches the currently active menu item, is in the currently active menu trail, or is in the currently active menu trail, excluding current page.
Combining these, you can (for example) add a "show on these pages" field on a content type "Sidebar messages", and with a Views block fetch all the sidebar messages referring to the currently viewed page.
But since this is standard Drupal tools, you can combine them to your heart's content. Some more complex examples:
- Add another menu reference field, "show below these pages". Using the Views filter "in the trail, excluding current page", you can have the sidebar content displayed on all sub pages to news, or whatever. Selecting "front page" would result in displaying the sidebar content on all pages except the front page.
- You can combine several filters with OR groups in views, to have several categories of sidebar content displayed in the same list (which means that one group doesn't have to be before/after the other group).
- Use DraggableViews to allow drag-and-drop sorting of sidebar content, on the page where they are displayed.
- Add contextual filters to the view to allow several clusters of sidebar-ish content. A contextual filter "slideshow" could return all slideshow-marked content relevant for the currently viewed page, and other contextual filters could give you header content or help-box content.
As said, much of this functionality is provided by (for example) the Context module. But (as far as I know), all these solutions depend on more or less fixed and developer-defined sections on the site. Relating sidebar content to active menu items has the advantage that site editors themselves can extend and change the structure – no developers needed, and no exported settings will be broken.
Other solutions build on nodes being tagged with particular terms, making related sidebar content show up. I've built a few websites with this kind of solution, and while they work quite well for node pages they break down completely when the client wants sidebar content to be displayed on a Views page. Views Menu Support doesn't mind – as long as there is a page, you can have a menu item ID.
As a bonus, you can combine this module with Menu Position and Rules Bonus Pack to fake active menu items. "When viewing a news item with the science tag, make the Science menu item active."
Interested? Download the dev version of the module and try it out. Feel free to help with bug reports, feature suggestions, documentation, patches and general ideas!
The screencast can be downloaded from archive.org and Vimeo.
