I'd like to create a PHP contexual filter for a view.

This code isn't right, but I want something like this:

global $node;
if ($node->type=="ABC") {
return 5880;

if ($node->type=="XYZ") {
return 6200;

How do I access the $node object in a PHP contexual filter?

Also, is there a better way to debug/troubleshoot this? I feel like I'm operating in complete darkness.

  • Please post it as an answer. – othermachines Sep 18 '15 at 19:59

You can access the $node object by doing this in the filter:

$node = menu_get_object() 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.