Closed (duplicate)
Project:
Location
Version:
7.x-3.x-dev
Component:
Location_views
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
16 Jun 2011 at 19:59 UTC
Updated:
27 Jun 2011 at 15:17 UTC
I have created a view in hopes of creating a page for a location search. But it seems to be not working. It's definitely possible that I'm not doing it right but I think I have it right.
Ohh, it works when I don't have it the filter as "Exposed", but when I do have it "Exposed", it breaks. Here's my view:
$view = new view;
$view->name = 'location_search';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Location Search';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Location Search';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
'title' => 'title',
'distance' => 'distance',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
'title' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
),
'distance' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
),
);
$handler->display->display_options['style_options']['override'] = 1;
$handler->display->display_options['style_options']['sticky'] = 0;
$handler->display->display_options['style_options']['empty_table'] = 0;
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = 'Location';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['external'] = 0;
$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['element_label_colon'] = 0;
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Field: Location: Distance / Proximity */
$handler->display->display_options['fields']['distance']['id'] = 'distance';
$handler->display->display_options['fields']['distance']['table'] = 'location';
$handler->display->display_options['fields']['distance']['field'] = 'distance';
$handler->display->display_options['fields']['distance']['label'] = 'Distance';
$handler->display->display_options['fields']['distance']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['distance']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['distance']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['distance']['alter']['external'] = 0;
$handler->display->display_options['fields']['distance']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['distance']['alter']['trim'] = 0;
$handler->display->display_options['fields']['distance']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['distance']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['distance']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['distance']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['distance']['alter']['html'] = 0;
$handler->display->display_options['fields']['distance']['element_label_colon'] = 1;
$handler->display->display_options['fields']['distance']['element_default_classes'] = 1;
$handler->display->display_options['fields']['distance']['hide_empty'] = 0;
$handler->display->display_options['fields']['distance']['empty_zero'] = 0;
$handler->display->display_options['fields']['distance']['origin'] = 'tied';
$handler->display->display_options['fields']['distance']['units'] = 'mi';
$handler->display->display_options['fields']['distance']['postal_code'] = '55425';
/* Field: Location: Latitude */
$handler->display->display_options['fields']['latitude']['id'] = 'latitude';
$handler->display->display_options['fields']['latitude']['table'] = 'location';
$handler->display->display_options['fields']['latitude']['field'] = 'latitude';
/* Field: Location: Longitude */
$handler->display->display_options['fields']['longitude']['id'] = 'longitude';
$handler->display->display_options['fields']['longitude']['table'] = 'location';
$handler->display->display_options['fields']['longitude']['field'] = 'longitude';
/* Sort criterion: Location: Distance / Proximity */
$handler->display->display_options['sorts']['distance']['id'] = 'distance';
$handler->display->display_options['sorts']['distance']['table'] = 'location';
$handler->display->display_options['sorts']['distance']['field'] = 'distance';
$handler->display->display_options['sorts']['distance']['origin'] = 'tied';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'ams_location' => 'ams_location',
);
/* Filter criterion: Location: Distance / Proximity */
$handler->display->display_options['filters']['distance']['id'] = 'distance';
$handler->display->display_options['filters']['distance']['table'] = 'location';
$handler->display->display_options['filters']['distance']['field'] = 'distance';
$handler->display->display_options['filters']['distance']['operator'] = 'dist';
$handler->display->display_options['filters']['distance']['value'] = array(
'latitude' => '',
'longitude' => '',
'postal_code' => '',
'country' => 'us',
'php_code' => '',
'nid_arg' => '',
'nid_loc_field' => 'node',
'uid_arg' => '',
'search_distance' => '100',
'search_units' => 'mile',
);
$handler->display->display_options['filters']['distance']['exposed'] = TRUE;
$handler->display->display_options['filters']['distance']['expose']['operator_id'] = 'distance_op';
$handler->display->display_options['filters']['distance']['expose']['label'] = 'Zip Code';
$handler->display->display_options['filters']['distance']['expose']['operator'] = 'distance_op';
$handler->display->display_options['filters']['distance']['expose']['identifier'] = 'distance';
$handler->display->display_options['filters']['distance']['expose']['required'] = 1;
$handler->display->display_options['filters']['distance']['expose']['gmap_macro'] = array(
'default' => '[gmap ]',
);
$handler->display->display_options['filters']['distance']['expose']['user_location_choose'] = array(
'default' => FALSE,
);
$handler->display->display_options['filters']['distance']['origin'] = 'postal_default';
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'locations/search';
/* Display: Attachment */
$handler = $view->new_display('attachment', 'Attachment', 'attachment_1');
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'gmap';
$handler->display->display_options['style_options']['markertype'] = '';
$handler->display->display_options['style_options']['latfield'] = 'title';
$handler->display->display_options['style_options']['lonfield'] = 'title';
$handler->display->display_options['style_options']['markerfield'] = 'title';
$handler->display->display_options['style_options']['enablermt'] = 0;
$handler->display->display_options['style_options']['rmtfield'] = 'title';
$handler->display->display_options['style_options']['tooltipfield'] = 'title';
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['displays'] = array(
'default' => 'default',
'page' => 'page',
);
$handler->display->display_options['inherit_exposed_filters'] = 1;
$translatables['location_search'] = array(
t('Master'),
t('Location Search'),
t('more'),
t('Apply'),
t('Reset'),
t('Sort by'),
t('Asc'),
t('Desc'),
t('Items per page'),
t('- All -'),
t('Offset'),
t('Location'),
t('Distance'),
t('Latitude'),
t('Longitude'),
t('Zip Code'),
t('[gmap ]'),
t('Page'),
t('Attachment'),
);
Comments
Comment #1
jbehshad commentedSame issue. I am trying to make it work as a Contextual filter but have had not luck doing so. I have tried it as a regular filter and exposed filter too.
Comment #2
dandaman commentedOK, I've done a bit of debugging and this is what I found.
It works fine for me if the filter is not exposed. If it is exposed, this is what happens starting on Line 478 of
location.views.inc:The problem is the
$filter->valuevariable in thatarray_merge()statement. When exposed, it looks like this:Looking at the code down the road, it looks like it's not expecting the extra level with the array inside an array and would work if that wasn't there. Where is that coming from and what do we need to do to fix this? Thanks!
Comment #3
dandaman commentedupdated the title to clarify that it's a Views-related issue.
Comment #4
K.MacKenzie commentedI am really excited to be posting this as I am fairly new to Drupal - (6 months) and this is the first contribution I am going to make to the community.
I believe I have a fix for your problem. I came across this problem myself and when searching for a solution this thread is all I could find.
By inspecting the form element using chrome I discovered the the filter type which I am using (and I believe you are too) is actually called latlon_gmap (not "tied"). (this is the filter that allows you to use a map to select a location to filter by). Currently in the location.views.inc file there is no case for latlon_gmap so I simply created one...
I inserted:
right after:
this is around line 475 of location.views.inc
After making this change my filter (when exposed) now works as intended.
If this solution isn't what you were looking for please say so and I will attempt to help you find yours, I believe I understand this part of the code now well enough to help.
Comment #5
dandaman commentedI don't think I'm using the "latlon_gmap" but you're probably right, it may not be the problem of the "tied" code either. I was trying to use "postal_default" as the filter and it works when the form is not exposed, but it breaks when the filter is "exposed". Thanks for the offer for help.
Comment #6
hellomobe commented+1
Comment #7
rooby commentedI have not been able to reproduce a problem.
I have imported the view from the original post (I changed only the node type filter to suit my node types) and it works.
Form the original post:
What do you mean by "breaks", do you get error messages, no results, incorrect results (if incorrect, how are they incorrect)?
Can you confirm the problem still exists in the latest views 7.x-3.x-dev and location 7.x-3.x-dev?
@Vandrico:
Thanks for catching that. That is actually a different problem to the problem in this issue, and it affects drupal 6 as well.
I have created a new issue for it at #1199910: Exposed proximity filter using gmap doesn't filter results
Comment #8
rooby commentedI know a while back I saw a problem similar to this, which was fixed by the commit at #1109240-7: exposed filter 'proximity' doesn´t work with latest VIEWS.
If you are using a location version from before that date (April 5th, 2011) then updating to the latest version will hopefully fix the problem.
Note that the symptoms of that bug was that the filter did not filter the results.
This could potentially be a duplicate of that issue.
Comment #9
dandaman commentedYou're right, this was a duplicate. I updated the modules to newer versions and that fixed it. Thanks for your help.