I was wondering if it's possible to create a custom node type with a custom field to relate it to another node content(same or diferent node type). And then in my node--customtype.tpl display the fields(render($content['myfield'])) of the custom node type but also to display all the fields of the related node and I want to do it programmatically.

I've been searching, and I found a module called References, but there's no documentation about how to use it exactly.

The other option that I thought is to add a int field to fill with the nid of the related content, but I don't know if it's possible to generate a query with that nid and append it to the $content['extrafield'] and render it on my node--customtype.tpl

But here you are the experts and I hope you can guide me with the correct way to do it.

1 Answer 1


I found the answer, there's a module named Entity references, this allows you to add and Entity Field in your custom node type, and with this you can relate to another contents. To use it you just need to add the field, select what do you want to point to, an that's all. To render the entity field and it's fields you need to add to you tpl something this:

<?php print render($content['field_myentityfield'][0]['node'][62]['fieldof_entityfield']['#items'][0]['value']); ?>

You can check it with devel.

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.