By apt94jesse on
Hello, I'm looking for the php code to use as a default argument for grabbing the content:nid in a contextual filter in D7/Views 7.
My view is outputting a block (not a page, so I can't grab the nid from the url) and I need the NID to be available to a regular filter (using the geolocation proximity filter module). I've posted the question there but with no luck, and since the specific question is more of a general php question, I'm hoping that the general forum can come up with an answer.
Thanks in advance for any help.
Comments
Where does the nid come from?
Where does the nid come from? If the block displays on node page (ie unaliases path of form node/{nid}} you can specify the default argument comes from the path (no need for PHP) even for blocks.
Thanks for your reply. The
Thanks for your reply.
The url contains the id of the page, however I need the nid of the node loading into the block. Here's the setup.
Two content types: page and feature. When viewing the page, there is a block that outputs a feature. I need to grab the nid of the feature content that's loaded on that page. That's why the url doesn't actually work, since it's a different nid than the content in the block.
How do you pick the feature
How do you pick the feature block node?
I'm not sure if I understand
I'm not sure if I understand your question. The feature block is output by views. I'm trying to use the "geolocation proximity filter" module to determine what nodes load first, but that shouldn't be relevant to my question.
Basically, how do I grab the nid in a contextual filter if the nid is not output in the url? Right now the feature block node is just pulled from the view with the content type filter in place. It's sorted randomly so each page displays a different feature.
Any chance you have the php
Any chance you have the php code I'm looking for? I don't want to be a bother but I just cannot find the answer anywhere else. Thanks in advance.
I do not know what you are
I do not know what you are after, it is not clear where the nid comes that you want to use.