I have created a view with an exposed Distance/Proximity filter.

The distance field for every result is always blank, no matter what. The distance is never filled in for the table.

But then there's a second problem.

Results only show up when, in the Distance exposed form, the value is null or zero. Any positive number I put in the distance radius form makes it return an empty result set.

I need help desperately.

Thanks.

CommentFileSizeAuthor
#6 location_distance_field_tied.patch1.05 KBBartVB

Comments

jazzdrive3’s picture

Any ideas for troubleshooting?

jazzdrive3’s picture

Any ideas?

jazzdrive3’s picture

So no one else has seen this problem?

jazzdrive3’s picture

Here is the query as it's showing in Views.

SELECT node.nid AS nid,
   node.title AS node_title,
   node_data_field_phone.field_phone_value AS node_data_field_phone_field_phone_value,
   node_data_field_phone.nid AS node_data_field_phone_nid,
   node.type AS node_type,
   location.lid AS location_lid,
   'Unknown' AS location_distance_3
 FROM node node 
 LEFT JOIN content_type_location node_data_field_phone ON node.vid = node_data_field_phone.vid
 LEFT JOIN location_instance location_instance ON node.vid = location_instance.vid
 LEFT JOIN location location ON location_instance.lid = location.lid
 WHERE (node.status <> 0) AND (node.type in ('location')) AND (0)
   ORDER BY location_distance_3 ASC

This is if the proximity field has been filled out. Notice the "AND (0)" at the end, so it returns nothing. If I empty the proximity field, that clause disappears, and every field is shown, with nothing in the Distance table fields.

Notice also that there is nothing pertaining to the zip code at all. So this views integration is completely broken.

Can someone address this?

BartVB’s picture

Priority: Critical » Normal

Same problem(s) here. The missing data in the 'distance' column seems to be caused in location_handler_field_location_distance.inc()

which contains:

    if ($this->options['origin'] == 'tied') {
      if (!empty($this->view->filter)) {
        foreach ($this->view->filter as $k => $v) {
          if ($v->table == 'location' && $v->field == 'distance' && $v->options['relationship'] == $this->options['relationship']) {
            if ($v->calculate_coords()) {
              $latitude = (float)$v->value['latitude'];
              $longitude = (float)$v->value['longitude'];
            }
          }
        }
      }

Which doesn't seem to pick up the lat/lon of the entered location in the filter.

The 'distance' field is filled properly if you choose 'static location' in the options for this field. Now the question is where the query function is supposed to get the lat/lon from.

BartVB’s picture

Title: Nothing showing up in Distance field » Empty Distance field when using Views filter
Version: 6.x-3.1-rc1 » 6.x-3.x-dev
Category: support » task
Status: Active » Needs review
StatusFileSize
new1.05 KB

Ok, looks like I fixed this issue (with my extremely minimal knowledge of the Views framework :D).

It only changes:

          if ($v->table == 'location' && $v->field == 'distance' && $v->options['relationship'] == $this->options['relationship']) {

into

          if ($v->table == 'location' && $v->field == 'distance' && ($v->options['relationship'] == 'none' || $v->options['relationship'] == $this->options['relationship'])) {

to handle the case where a view doesn't have any relationships. Not sure if this is the way to go but works for me :)

ankur’s picture

bump

podarok’s picture

Status: Needs review » Active

bot recall

podarok’s picture

Status: Active » Needs review

bot

Status: Needs review » Needs work

The last submitted patch, location_distance_field_tied.patch, failed testing.

legolasbo’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

Closing old D6 issues as D6 is end of life