0

I'm getting this error when I run the code below, in reference to $color module:

Notice: Trying to get property of non-object in cotyhouse_preprocess_html() 

function cotyhouse_preprocess_html(&$vars){
  // Check if on an article node page
  $node = menu_get_object('node');

  $color = $node->field_title_color;

  print $color;

}    

When i output it via dpm, it says its an object, so im a bit confused why it would throw an error. The field value does indeed come through.

1 Answer 1

0

menu_get_object('node') should be: menu_get_object()

No need for node as its implied when you call that function.

Also you need to put it in a conditional:

if($node = menu_get_object()) { }

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.