My customer has a "directory" that currently shows filter boxes at the top and the full (unfiltered) list below the filter boxes. She wants to eliminate the full list and not show any entries until the submit button is used, presumably with filters selected. How can this be done? [And no, I'm not afraid of php code snippets.]

Comments

nancydru’s picture

I have tried the argument handling snippet at the top of http://drupal.org/node/70145, but that prevents me from ever being able to leave all the filters at "" to get the full list.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

mooffie’s picture

Have you tried to wrap the snippet you have in a check for URL parameters? something like:

if ($_GET) { // if there are any parameters, then...
  // the snippet
}

(Setting all filters to "" still puts them on the URL so the snippet will execute.)

EDIT: you may need to do if (!$_GET) instead of if ($_GET), depending on what you're trying to do.

nancydru’s picture

On first entry, $_GET contains array('q' => 'directory'). "Directory" is the View's URL. After I filter, $_GET also contains the three filters. So how does this help prevent the View from running until there are filters present?

I tried this, but it didn't stop the full list from coming out.

if (count($_GET) == 1) {
  $_GET['filter0'] = 'xx';
}

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

nancydru’s picture

This is really hokey, but it worked.

I selected "Node ID" for the only argument. The default is "display all values" and the Option is "equal."

My argument handing code is:

if (count($_GET) == 1) { $args[0] = 1; }
else {  $args[0] = NULL; } 
return $args;

There is already a filter on node type, and node/1 is not of that type.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database