I created a view that lists items with five fields in each item.

I need to give site visitors a compact, duh-proof UI above the list so they can change filtering and/or sorting of that list to their liking.

While possible I missed something, I found no module already existing to serve my needs.

While I'm fairly new to Drupal, I'm not intimidated by PHP, CSS, and xHTML, ready to dive into building a custom module if need be after studying the relevant documentation.

That said, the goal isn't just to find a solution. The goal is to find the best solution, and that's why I'm posting this.

Site traffic could become heavy, so whatever solution is implemented, it needs to be efficient.

My resources in building the overall site are already embarrassingly limited (I may be able to afford buying the Pro Drupal Development book), so the solution will need to be basic for 1.0 with feature expandability in mind.

Am I right to assume that I need to build a custom module basically providing a Web form (using Form API) accepting user input (a filter and/or sort change) and submitting that input via the Views API to quickly modify the list?

Would I then use my custom module to layout the filtering/sorting UI with the view below it in a content type? Or is there a better way?

Any guidance offering excellent strategies, and/or traps to beware of, would be deeply appreciated.

Comments

rstaylor’s picture

If I understand what you're asking, it sounds like you just need to expose some filters. (Edit the view, create some filters and for each one that you want the user to be able to change, click the 'Expose' button. That'll give some additional options and filter controls above the view.)

You might need a custom or contrib module if you need filters or operators other than those that are built into Views, but that's a lot more in-depth. Experiment to see if the standard ones are sufficient first.

To make fields sortable, under 'Basic Settings', set the Style to "Table" and click the gear next it; that should give you a list of fields with "Sortable" and "Default Sort" options.

(Note: I'm referring to Views 2 on Drupal 6. The same things can be done on Views 1, but the UI is different.)

Scott McCabe’s picture

First, thank you for your reply.

Second, to elaborate, each list item is basically a teaser (click a link, or maybe click anywhere in the teaser, to leave the list and experience the corresponding content node, returning to the same list -- i.e. same filter and sorting settings before user left -- when finished with that content node).

I need fairly precise control over the styling (positioning and other elements -- e.g. font coloring, etc.) of each teaser (or at least each type of teaser associated with the different content types), which led me (perhaps prematurely) away from relying on Drupal's teasers which seem too limited for my needs here, opting instead for using Views to build them (my lack of relevant Drupal knowledge here leaves the waters muddy for me).

By default, the list will only show the last ten teasers (i.e. teasers for the ten most recent content nodes published).

The list represents access to an ever-growing library of content. The list in full will get unwieldy fairly soon after site launch, so it's important that users have a good filtering system to produce fairly short lists to meet their needs. To keep it duh-proof, I'm contemplating just giving users a pop-up list of presets (filter(s) and optionally sort(s)) to choose from (or two preset lists for more flexibility -- one for filters, the other for sorts), eventually basically giving them the ability to build their own 'favorite presets' list.

Taxonomy terms within content nodes will probably be links to create a filtered teaser list corresponding with the selected term.

An RSS feed and other new content notification options will also likely be available.

I'm going to spend time studying the Views advanced help page to get more comfortable with Views, and will likely pick up the Pro Drupal Development book very near term.

If anyone has any further advice, I warmly welcome it.

parvardeh’s picture

Dear Scott,
I am wondering if you found a solution or not.
I want to make a website with the same functionality that basically lets user to add filters to a view that I have made.
So If you have found something please let me know.

Thanks.