Location Views Province filter no longer contains drop-down menu in 4.7

droplits - February 11, 2007 - 20:26
Project:Location Views
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community
Description

I was wondering with all the development with this sub-module and the locations module if it is by design that there is no longer a drop-down menu for province filters, or if it is a bug? I've combed through the module itself and the changes but nothing is jumping out at me.

It used to be that you could select , =, and not= with the filter, and now I see that it is the normal "Is Equal To" through "Does not Contain". As a consequence I am unable to provide a "search by state" drop-down menu using an exposed filter. The user can type in the state abbreviation, but that seems to be against the normal filtering method, which is a drop-down menu.

I'm wondering if this is by design, and if so what I would need to do to display the pull-down menu of states again.

Thanks for such a great module. I use it all the time.
Scott

Here are a few screenshots if that helps see what I mean and what the problem is:
http://test.declarepeace.org/before-after-location-views.html

Here is the export of the view:

  $view = new stdClass();
  $view->name = 'UserListing';
  $view->description = '';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = 'User Listing';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'table';
  $view->url = 'userlisting';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '10';
  $view->sort = array (
  );
  $view->argument = array (
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => 'User',
      'handler' => 'views_handler_field_nodelink',
      'options' => 'link',
    ),
    array (
      'tablename' => 'location',
      'field' => 'city',
      'label' => 'City',
    ),
    array (
      'tablename' => 'location',
      'field' => 'province',
      'label' => 'State',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'status',
      'operator' => '=',
      'options' => '',
      'value' => '1',
    ),
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'content_user_profile',
),
    ),
    array (
      'tablename' => 'location',
      'field' => 'province',
      'operator' => 'contains',
      'options' => '',
      'value' => '',
    ),
  );
  $view->exposed_filter = array (
    array (
      'tablename' => 'location',
      'field' => 'province',
      'label' => 'State',
      'optional' => '1',
      'is_default' => '0',
      'operator' => '1',
      'single' => '0',
    ),
  );
  $view->requires = array(node, location);
  $views[$view->name] = $view;

#1

Darren Oh - February 13, 2007 - 22:51
Category:bug report» support request
Status:active» closed

The drop-down menu is a different filter called Province Selector.

#2

droplits - February 15, 2007 - 02:41
Status:closed» active

I just installed the location module and the views module both the most recent 4.7 versions, on a clean install on a 4.7 test site and activated the modules. I don't see anything in the add filter drop down views menu named Province Selector, just Province. I wonder if anyone else can verify that they either see "Location: Province Selector" when creating a view? Thanks.

#3

Darren Oh - February 15, 2007 - 03:03

I was using the Drupal 5 module.

#4

droplits - February 16, 2007 - 03:48
Title:Location Views Province filter no longer contains drop-down menu» Location Views Province filter no longer contains drop-down menu in 4.7 and exposed filter results returns error in 5.1
Category:support request» bug report
Priority:normal» critical

Thanks Darren for replying.

Not being a php coder myself I just ran a test with a fresh install of Location and Views with a fresh install of Drupal, 5.1 because I'll be developing a drupal5 site in the near future with the need for a views filter with a province selector. I activated location for the story content type and then created a story node with a location. I then enabled the default view location_table and added a Location: Province Selector filter and exposed the filter with it set to Optional and Lock Operator. Then when I visited the view and select and submit the province I get the following error:

    * user warning: Unknown column 'location.province_select' in 'where clause' query: SELECT count(node.nid) FROM node node LEFT JOIN location location ON node.vid = location.eid WHERE (node.status = '1') AND (node.type IN ('story')) AND (location.type = 'node') AND (location.province_select = 'us-CA') in /var/www/vhosts/XXX.org/subdomains/drupal/httpdocs/includes/database.mysql.inc on line 172.
    * user warning: Unknown column 'location.province_select' in 'where clause' query: SELECT node.nid, node.title AS node_title, node.changed AS node_changed, location.street AS location_street, location.city AS location_city, location.province AS location_province, location.country AS location_country, location.postal_code AS location_postal_code FROM node node LEFT JOIN location location ON node.vid = location.eid WHERE (node.status = '1') AND (node.type IN ('story')) AND (location.type = 'node') AND (location.province_select = 'us-CA') ORDER BY node.title ASC LIMIT 0, 10 in /var/www/vhosts/XXX.org/subdomains/drupal/httpdocs/includes/database.mysql.inc on line 172.

While this particular problem doesn't show up in my 4.7 site (with the 4.7 version of location and views), it is because there is no "Location: Province Selector" in the pull -down menu in the views filters edit form in the first place.

For the 4.7 test I did end up changing:

  $tables['location']['filters']['province'] = array(
    'field' => 'province_select',

to

  $tables['location']['filters']['province_select'] = array(
    'field' => 'province_select',

and then cleared the cache and was able to get the filter to show up in the filter of the view, and the view itself, but it returns a no value.

If I find anything else I will post here, but like I said, I'm not a PHP programmer, unfortunately, but my only new year's resolution is to learn ;) I can provide help testing anyone's solution.

Thanks,
Scott

#5

droplits - February 16, 2007 - 03:50
Priority:critical» normal

Just changing the priority to normal, as the module works fine outside of the Province selector issues.

#6

csevb10 - March 22, 2007 - 22:30

I needed/wanted the province select. So here's a patch against the latest version so that you can use the province select.
I decided to filter on both the country and the province since both pieces of information are present, but it's easy enough to modify it so that it only checks against province.
wpo

AttachmentSize
location_province_select.patch 1.37 KB

#7

csevb10 - March 22, 2007 - 22:31
Status:active» needs review

Whoops. Modifying the status.

#8

csevb10 - March 22, 2007 - 23:28

I hadn't accounted for the fact that you can actually search on the countries in the provinces/states drop down.
This new patch simply generalizes things just a bit to account for that case.
The only case that isn't handled now is the "NOT LISTED" case. If someone has an idea of the logic behind that element (no country? no province? neither?), I'm more than willing to incorporate that. Until then, here's the new patch.
wpo

AttachmentSize
location_province_select_0.patch 1.4 KB

#9

Darren Oh - March 29, 2007 - 15:16

On Drupal 5, I got the province select drop-down to work without patching. Simply choose the filter "Location: Province Selector" and select the operator. For some reason the other operators do not return any results.

#10

Darren Oh - March 29, 2007 - 16:55
Title:Location Views Province filter no longer contains drop-down menu in 4.7 and exposed filter results returns error in 5.1» Location Views Province filter no longer contains drop-down menu in 4.7

#11

csevb10 - March 30, 2007 - 00:42

Can you give me a little information on how you managed to make it work without patching?
I attempted to use it a number of times, and it was running an illegal query for me.
I'm using php 5 & drupal 5
Any thoughts?

#12

Darren Oh - March 30, 2007 - 16:52

The most important part of my comment got filtered out. The province selector only works with the <all> operator.

#13

csevb10 - March 30, 2007 - 17:18

Ok, that makes some sense. The patch, then, fixes functionality for selecting = or !=

#14

Darren Oh - March 30, 2007 - 17:36

The operators only make sense if users can select more than one province .

#15

csevb10 - April 2, 2007 - 21:30

Ok. I'm not sure what version you're using or how you're using it, but I just verified that, without the patch, this doesn't work for selecting provinces.

I entered test data in NY & CA, and cannot pull a list of NY or CA using the Province Select.
I get the following error using the latest code base when searching for California:
Unknown column 'location.province_select' in 'where clause' query: SELECT count( DISTINCT(node.nid)) FROM node node LEFT JOIN location location ON node.vid = location.eid WHERE (location.province_select = 'us-CA')

The problem exists both for setting up a filter on a view and for exposing that filter using Drupal 5 at the minimum.
This is most definitely a bug in the location_views.module

#16

Rob Loach - May 31, 2007 - 19:31

I was experiencing the same error as dividespace, applied csevb10's patch, and then it worked as expected. Thanks a lot, csevb10.

#17

aswalla - July 11, 2007 - 13:54

I was also experiencing the same problem.  The patch worked for me - thanks!

#18

nk126 - November 7, 2007 - 20:13

I also just came across the same error, applied the patch, and now it works for me. Thanks!

#19

Darren Oh - November 7, 2007 - 20:48
Status:needs review» reviewed & tested by the community

Please set things that work to ready to be committed.

#20

JuliaKM - November 19, 2007 - 01:51

I ran into the same problem. After applying the patch, I was able to filter results using the Province Selector. Thanks!

#21

alextronic - August 23, 2009 - 02:02

I REALLY can't find the file location_views.module, I'm on D6 using Views2 and the Location Module... how and where can I use that patch?
Thanks so much in advance,
Alex.

 
 

Drupal is a registered trademark of Dries Buytaert.