0

I have the following code, but how do I add a conditional to check if the menu_get_object() is grabbing a node object or not? Im mainly using this in my contextual filter in views and its throwing an error on etity_metadata_wrapper() as its trying to load a node page while its in the view page. I'm not sure what condition to check before it returns anything. thanks!

$node = menu_get_object();
$wrapper = entity_metadata_wrapper('node', $node);
$tid = $wrapper->field_device_type_vocabulary[0]->tid->value();
return $tid;

enter image description here

1 Answer 1

1

If you are on a non-node page, menu_get_object() returns NULL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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