Hi,

I am trying to expose the Location province field in views.
It should show all the nodes when the exposed field is empty (no value in the filter)
But it does not give back any node.
Did someone heve the same problem?

CommentFileSizeAuthor
#6 province-filter.patch1 KBakahn

Comments

erantone’s picture

I also got this problem.
Actually this is a serious problem and you can not even filter by province, even when the filter province is set to some value.
Any hints ?
Thanks!

erantone’s picture

I also got this problem.
Actually this is a serious problem and you can not even filter by province, even when the filter province is set to some value.
Any hints ?
Thanks!

erantone’s picture

I found the bug:
I commented out //$value = array_keys($value); !!! ?
and added a if instruction: if (empty($this->value[0])) return;

on file location_handler_filter_location_province.inc in subdir. handlers.

  function query() {

    if (empty($this->value[0]))
	  return;
	  
    $country = $this->grovel_country();

    $this->ensure_my_table();
    $field = "$this->table_alias.$this->real_field";

    // Normalize values.
    $value = $this->value;
    if (is_array($value)) {
      //$value = array_keys($value); !!! ?
      if (count($value) == 1) {
        // If multiple is allowed but only one was chosen, use a string instead.
        $value = reset($value);
      }
    }
...
carlogen’s picture

Category: support » bug
Status: Active » Patch (to be ported)

Erantone,

I have applied your solution and it works.

Thanks

matt_c’s picture

Thanks for sharing your solution erantone!

It saved us lots of time.

akahn’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1 KB

Here it is as a patch against HEAD. Could a maintainer please weigh in on if this is a good way to handle this bug?

bdragon’s picture

Status: Needs review » Fixed

Fixed, I hope.

http://drupal.org/cvs?commit=164846
http://drupal.org/cvs?commit=164847

A workaround in 3.0, by the way, is to uncheck "force single."

akahn’s picture

Awesome, thanks bdragon!

smscotten’s picture

Is this the same as the issue I'm running into? I'm using the stock location/directory view and on countries for which there is no Province data. When I click on "Singapore" for example I am offered only a link to the very same URL with the text "unknown." I'd like to have an easy way for my users to get from there to location/directory/sg/all without having to know to type in "all" in the address bar.

Example: http://www.penshops.info/location/directory/sg

I applied the patch provided in post #6 and still encounter this same behavior, so though it looks like the same issue, perhaps it is not?

I got onto a track of using a php validator to check location_get_provinces(), but even that can't take action other than pass or fail. I tried to update the argument from within the php validator, but that got me (for example) 'us/all' in the SQL. I could try hacking the URL and sending a redirection header from the php validator, but that seems like a highly inelegant solution.

If this is a different issue, I apologize.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

bartclarkson’s picture

Unchecking "force single" worked for me, up to a point. You're in trouble if you are exposing more than one filter, such as City. In that case, you must apply the above patch, because otherwise the query that runs includes "...AND (location.province = '')..."

In my opinion, this patch or something like it definitely needs to go in the head.