drupal 8 get taxonomy term value in node

后端 未结 6 958
既然无缘
既然无缘 2021-02-08 05:36

Drupal\\node\\Entity\\Node Object ( [in_preview] => [values:protected] => Array ( [vid] => Array ( [x-default] =

6条回答
  •  温柔的废话
    2021-02-08 06:12

    To build on VJamie's answer.

    You will need to either set a use statement at the top of your script;

    use Drupal\taxonomy\Entity\Term;
    

    Or, prefix the class instance with the namespace;

    $term = \Drupal\taxonomy\Entity\Term::load($node->get('field_destination')->target_id);
    

    That will get rid of the fatals.

提交回复
热议问题