0

In Views PHP code, I could render a field by :-

<?php
  print drupal_render($data->field_field_my_text); 
?>

But this only seems to work field with type Text. I have a field which is Taxonomy (Term Reference) and I am trying to output that through the above code but it's not working.

This is what I wrote:-

<?php
      print drupal_render($data->field_field_my_category); 
    ?>

Unfortunately, this is not working. Any idea what I should do here?

Thanks.

1
  • Instead of adding PHP code in database I would suggest write a template file for it and write your code there. Jun 30 '15 at 6:37
1

I can't comment because of rep.. Use devel module and use the dpm() function in your php for some debugging, drill down and find the value you are looking for then double click the value in the debug widget and it should tell you your field value.

here's my guess:

$data->field_field_my_category[0]['raw']['value'];

Might be slightly different if it's a tax term but devel is your best friend and you should use it quite frequently. Stop guessing and start debuging (best advice i've ever gotten).

0

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.