0

I'm working on a node template for my content types and use Entity reference to reference my content with each other. THe machine name of my entity reference field is og_group_ref. In my node template I used print_r(get_defined_vars()) to show all existing varialbes to select variables I need. When I look for og_group_ref I only get the target_id of that reference:

[og_group_ref] => Array
            (
                [0] => Array
                    (
                        [target_id] => 65
                    )
            )

So, my question is how do I get the title of that referenced node?

1

For example, if I remember node structure right:

  • Load node by id into $node
  • Put title to $node_title

    $node = node_load(og_group_ref[0][target_id]);

    $node_title = $node->title;

All you need is to get og_group_ref object/element

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.