I'll describe my particular problem/use case, and then ask some questions and link to related issues to see if others think that solving those other issues will solve mine.

I have a clunky way of doing something. Please tell me if you have a better idea for how to get this done. It is using location module (with 2 hacks), gmap, fieldview, and views.

I have a bunch of "groups", each group has a cck location.

I hacked location module to save the nid and genid as in #366880: Location CCK fields not compatible with views

I made a view using this hack to location proximity search #357295: Proximity Search based on lat/lon, using views arguments

the view I made, lists other groups within 20 miles of a certain lat/long

the trouble is, to list groups near say Oak Park, IL, I made a display (page) for the view, and hard coded in that display the lat/long for Oak Park, and the distance of 20 miles.

Then I edited the group content type for the Oak Park group, and selected the proximity view for groups near Oak Park as the viewfield ( http://drupal.org/project/viewfield )

And I display the search results like:

  if ($node->field_neargroups[0]['view'] == NULL) {
    echo "<p>Web Admin needs to create in Views and select in Group edit a view for nearby Groups.";    
  } else {
    echo "<h2>Nearby Groups</h2>";
    print $node->field_neargroups[0]['view'];
  }

So, I figure now, I have to make a display for every other group I have, AND edit each group page, and select that certain view in the viewfield in that Group...

I'm hoping, crossing my fingers, to find a solution that will let me pass in as an argument to the view, the lat/long from the Group to the view and then that can be used instead, so I can have each Group displaying the same "view", but using an argument.

and since my Groups are all displayed with the url path alias of group/groupname, I could make a block to display the view... and then tell the block to only appear on the group/* pages...

right now, I'm overriding the display of the Group nodes anyway (see the printing of the viewfield above), and so I can access the variables for lat and log like:

$node->field_grouplocation[0]['latitude']
    39.120036 
$node->field_grouplocation[0]['longitude']
    -88.547716 

So I figure, I should be able to send the lat/long to the view, and tell the view to suck in the lat/long as arguments.... but I'm lost as to how to piece it together.

I'm not sure, but these might be the issues related to this:
#391160: CCK/Views: location_instance fix
and
#321114: Fixing exposed filters in Views for UK and US postal code proximity search (not cck location)

While rereading 321114... I saw an old post of mine from nov 2008, and I had a good idea I can re-use now... :) to make the distance for the proximity search really big, but limit it to 5 results... to get the nearest 5 Groups... I'm going to go try that. :)

Please let me know if anyone has a good idea for how I can avoid making a display in my view for each group and hard coding the lat/long in the search. Thanks!

Comments

YesCT’s picture

Title: proximity search based of views argument for lat/long » proximity search based on views argument for lat/long
rorymadden’s picture

This is exactly what I am trying to do as well. And I want to avoid hard-coding a couple of thousand views.

Also as there is a proximity field which uses the user's location why does the proximity filter not work if the lat/long are left blank and it use the user location as the input?

Hopefully one of you geniuses out there can either tell me how to do it using the current functionality or submit a patch as this is way above my head.

Subscribing

mjvesper’s picture

Subscribing

YesCT’s picture

YesCT’s picture

Title: proximity search based on views argument for lat/long » proximity search based on views argument for lat/long for cck locations
YesCT’s picture

Status: Active » Closed (duplicate)

duplicate of #357295: Proximity Search based on lat/lon, using views arguments (but I dont know if that one is for the native locations instead of the cck locations. but I'm using the vid hack anyway, so I think it is a duplicate.)