[support] Drupal 7: Search Woes

Al Sessions fultonchain at gmail.com
Wed Apr 27 20:58:04 UTC 2011


Thanks, Joel.

Exposed Filters was initially the way I wanted to go.

However, I can't seem to get Views to filter by fields.

I have a date_of_birth field (plain text) that seems unfilterable.

If I filter on node:title, there is no problem. I can expose the
filter and get the results I want.

However, it doesn't seem to work with fields (I've tried several).

The code you provided seems simple enough, but I'm concerned about
creating custom forms and embedding views. I don't know who is taking
over this site and would far rather to everything from the GUI than
programatically.

-------------------------------

On Wed, Apr 27, 2011 at 10:58 AM, Joel Willers <joel.willers at sigler.com> wrote:
> I'd use Exposed Filters, personally.  If that doesn't work, you could always create a custom form and when you hit 'Search' it THEN runs the View (using the Views API) with those filters.  This method, of course, takes a bit of programming, but it isn't too hard, actually.
>
> Here's an example from Views2 (You'll have to find the correct Views3 functions, if they've changed) that searched for items within 15 miles of the zipcode entered in the form:
>
> (set $zipcode to the $_POST information)
>
> $view = views_get_view('name_of_view_example');
> $view->exposed_input['distance'] = array('postal_code' => $zipcode, 'search_distance' => '15', 'search_units' => 'mile');
>
> $displayview = $view->preview();
> print $displayview;
>
> Hope that helps some.
>
> Joel


-- 
Al Sessions


More information about the support mailing list