[support] Drupal 7: Search Woes

Joel Willers joel.willers at sigler.com
Wed Apr 27 21:43:06 UTC 2011


Again, this is Views 2 that I'm using, but having set up a Content Type with additional CCK fields (Just a field in D7, if I recall).  In D6 it's Content:name_of_field, in D7, I think it's Field:name_of_field.  

Joel 


-----Original Message-----
From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On Behalf Of Al Sessions
Sent: Wednesday, April 27, 2011 3:58 PM
To: support at drupal.org
Subject: Re: [support] Drupal 7: Search Woes

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
-- 
[ Drupal support list | http://lists.drupal.org/ ]


More information about the support mailing list