I'm using Drupal 6, and the customer has asked for a way for the user to switch between a list-of-nodes view, and a table view. The Basic settings section in Views does not offer a Exposed option, and my Googling has turned up nothing useful in this regard. I'm a somewhat experienced as a Drupal themer, and I could make a duplicate set of Views manually with a different settings to achieve this, but if there's an easier way, I'd like to have your insights.
4 Answers
I would most likely go for Views Display Tabs or Quick Tabs (and I would lean towards Quick Tabs because it has a d7 version and is more active).
-
Maybe I didn't explain it well, but this doesn't solve my problem. I've used Quick Tabs, but for that I would still have to make a separate view for each kind of display I want, right? What I want is a way to use the same view but give the user a switch to see it in two different ways, as tabular, or as a list of nodes. Thanks for the idea, though. Commented Jan 18, 2012 at 7:26
Creating a new/separate view (with a different display type) is not the best way to go about it. Because if you take that approach your view query will be executed twice when the user switches from one style to the other.
I would do it by letting a single view show selected unformatted fields of the node and then add required JS/CSS to render the same HTML in two different styles depending on the option selected by the user.
Advantages
view runs only once
no page reload on switch on display preference
- better for user experience
Disadvantages
- requires slightly more time than if you were to create 2 separate views
-
This seems to be the answer that gets closest to what I want. Unfortunately, I'd be switching between a view which is a list of nodes and a view that would be tabular data (in columns). I suppose I could use jQuery to rewrite divs as tds, but that seems a bit heavy. Or I could use the css display:table-cell rules as a style-sheet switcher but I lose IE7 support, right? Anyway, thanks, I will probably go with something along these lines. Commented Jan 18, 2012 at 7:36
For anyone running across this issue but need it for D7 (I know the question is for D6) Checkout the View Modes module. It adds Views display plugin which provides alternate display modes that can be switched to for a single View.
Views Modes has version for D6 at the github and there is demo at www.ugandawatch.org which is running at D6 release.