Created
October 19, 2018 16:46
-
-
Save DanLaufer/f76241520365dac460dff8f0dc5a964b to your computer and use it in GitHub Desktop.
Drupal 8 - Drill down from Node to paragraph reference to paragraph entity to taxonomy reference field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function example_preprocess_node(&$variables) { | |
$node = $variables['node']; | |
$paragraph = $node->field_paragraph_example->entity; | |
$nested_paragraph = $paragraph->field_another_paragraph_ref->entity; | |
$term = $nested_paragraph->field_example_term_ref->entity; | |
// The following simple syntax works when you just need the first value of the field: | |
$textfield_value_on_term = $term->field_exampletext_on_term->value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment