views:

313

answers:

2

Using Drupal 6, Views 2 with exposed filters, I'm trying to determine the best way to convert the select list to a list of links, each with a count of matching nodes. For instance instead of what I get by default, as a select list:

<select name="state" class="form-select" id="edit-state" >
<option value="All" selected="selected">&lt;Any&gt;</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
...
</select>

I'd like to get something like

<p>Restrict results by state:<br />
<a href="...">Alabama (15)</a><br />
<a href="...">Alaska (7)</a><br />
...
</p>

With each link showing the count in parentheses and drilling down in the same way that selecting one of the options in the first code block would.

Could you provide any pointers on how to approach this? Thanks.

A: 

What you are after is not something views was meant to do. It probably would be possible to do, but it will be slow and hard to implement.

Instead you should take a look at the module Acquia has made for Apache Solr. It does faceted search, which is what you really are trying to make. If your case is simple enough you might not need something so fancy. But it's just a matter of time before you do. Performance will become a big issue since you would need to do a query per state to get the counts.

googletorp
Thanks for pointing me in the direction of faceted search ... I'm going to pursue the Faceted Search and Faceted Search Views modules. Smallish site I'm working on so I think we'll hold off on Solr.
Dan U.
+1  A: 

Solr is slick, but also check out the summary option in Views. You can see an example of this in the arguments section of the "Archive list" view that comes with Views.

There are some other faceted browsing modules on drupal.org as well but I haven't got any personal experience with them.

stephthegeek
Thanks -- good tip and I'll follow in this direction.
Dan U.