I tried to search for a solution or question to this but couldnt fin anything, so sorry if its a duplicate.

Basically I have a panel page (custom) in which i used the content id argument. node/%node/custom. When I use distance / proximity filtering in a view and select "Entity from URL" it is not picking up the arguments and displaying the nodes closest to that page when attached to the panel.

If i put the same view in the original node ie. node/%, it works fine, but when I use a custom panel OR even a custom page view with a custom path ie. node/%/custom, it doesn't. It only works if the view is attached to the actual node (node/%). Pretty much all of my other views work, my titles carry over, and drupal as a whole knows that these custom views / panel pages have a context of the relevant NID, but proximity filtering doesn't. I am guessing this is because there is no contextual filter setup and proximity filtering works off its own algorithm which is ignoring any sub / custom pages that carry the same nid in the url ie(node/%/whatever).

It seems proximity filtering ONLY looks at the actual node, not any context pages (either from views or panels) based off that node. Does anybody know how I can get proximity filtering using Entity from URL working with any subpages of that node? Perhaps a work around?

I really need this functionality and wasted more than 3 days trying 100 different ways to get this to work, to no avail. Ideally I think the "Entity from URL" feature should look at any page with the context of the nid (as most views, blocks, and modules do), not only at the root node - it should work almost like a contextual filter.

CommentFileSizeAuthor
#2 proximity.png140.71 KBBrandonian
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Exploratus’s picture

Issue summary: View changes

Made it a tad more detailed.

Exploratus’s picture

Bump. :)

Brandonian’s picture

Status: Active » Postponed (maintainer needs more info)
FileSize
140.71 KB

@Exploratus, I've been able to successfully create a view with proximity filtering set up and firing correctly as a panel pane, but I may not be hitting your exact use case. Attached is an image that shows my current setup.

One caveat for the proximity filters/contextual arguments is that we use menu_get_object() instead of pulling directly from the views argument object. This is probably the source of your issue, however I'm confused as the situation where you would have a node load correctly at node/%/custom and have menu_get_object not load the entity id properly. Is the node in the url the one you want to reference for a proximity search, or is it a node referenced in one of your panes somehow?

Exploratus’s picture

Hi Brandonian.

Basically if I have:

node/example

and load a view with proximity filtering, everything works perfectly in a panel pane.

if i create a custom panel page with a context so its:

node/example/largemap

The proximity filter no longer picks up the current node as the reference node to filter items in proximity to it.

I know the context works, other view work perfectly, the only view that doesnt work is the one using the proximity filter, because the filter does not recognize the context page.

I have a view that centers on the current node and that works perfectly, as it grabs its context from the contextual filter. Both on node/example, and node/example/largemap, it works perfectly.

Nevertheles, my other view using proximity only works on node/example. The field options where I select "Source of Origin Point" doesnt seem to pick up the context page argument. node/example/largemap doesnt recognize that its the same as node/example in terms of context.

To test, create a custom panel page and pass the Node ID context to it. (node/%/whatever) Create a view with a contextual filter to current node. It will work fine. Now do the same but using proximity filtering and pick the current node for "Source of Origin Point". It wont work. Same thing happens if you do a view page, it doesn't have anything to do with panels. IMHO its definitely something with the filter, I just dont know enough PHP to figure it out.

fonant’s picture

I have this problem too.

If I create a Views page, with a URL of node/%/nearby and as a menu tab, the "Entity from URL" results in all the proximities being zero. If I create a block as well, the "Entity from URL" works fine on the main node View page node/%, but it also fails on the nearby tab with the URL node/%/nearby.

It does look as though menu_get_object() should return the node from node/%/nearby, but in fact it doesn't.

  • menu_get_object() doesn't work for the Views-generated sub-path of node/%/nearby.
  • menu_get_object('node', 1) doesn't work.
  • menu_get_object('node', 1, 'node/%/nearby') doesn't work.
  • menu_get_object('node', 1, 'node/%/notavalidpath') works nicely!

The problem is that menu_get_object() is using the menu router table, which works for all defined node URLs like node/% and also for any URLs of the form node/%/something-else that aren't being handled by another router item. In these cases menu_get_item() returns

Array ( [path] => node/% [load_functions] => Array ( [1] => node_load ) ... )

But in my case Views has added a menu router entry for node/%/nearby and menu_get_item() returns:

   Array ( [path] => node/%/nearby [load_functions] => Array ( [1] => views_arg_load ) ... ) 

so menu_get_object() does nothing because it requires the load_function to be "node_load" by default.

Result: menu_get_object() works on the node page, but not on the View-generated page with a sub-path.

Exploratus’s picture

Glad to see someone else was able to recreate. Hopefully someone can come up with a solution, a little beyond my technical ability. :)

Exploratus’s picture

Issue summary: View changes

More cleanup.

Adirael’s picture

I'm having the same issue in 7.x-2.1 and I plan to try to fix it and contribute a patch. Meanwhile I'm using a Contextual Filter with a PHP Code "Provided default value". I'm using the following code to return the latlong value of the field.

$node = node_load(arg(1, current_path()));
$geolocation = field_get_items('node', $node, 'field_geolocation');

return ($geolocation[0]['lat'] . ', ' . $geolocation[0]['lon']);

If someone wants to use it you'll need to replace "field_geolocation" with your field name and probably do some validation (Did the node load? Is the field empty? Are the values valid?) to avoid nasty errors.

DerTobi75’s picture

Hi,

got the same problem! Did you have any success with a path, Adiral?

Regards,

Tobi

jemisond’s picture

Adirael- thank you so much!!! I've been trying for hours to pass geo data from a panels page to views. Works great!

abhi4c4@gmail.com’s picture

using panles module and add some custom pages in my website. in this process i am getting blank pages when we given wrong path. please any one help me i am trying last 3 days onwards. i tried different types to solve those issues. but i am not getting well.

abhi4c4@gmail.com’s picture

Got the same problem any one success with the path...