I use the following code to pull up a referenced entity in my product template.

 <?php if (!empty($node->field_related_product['und'])): ?>
    <p class="related-product"> <strong>Related Products:</strong>
    <ul>
      <?php
           foreach ($node->field_related_product['und'] as $related) {
        ?>
      <li> <a href="/node/<?php print $related['target_id']; ?>">Item # <?php print $related['entity']->title; ?></a></li>
      <?php   
			}
			?>
    </ul>
    </p>
    <?php endif; ?>

It keeps on giving me the following error:

  • Notice: Undefined index: entity in include() (line 89 of node--products.tpl.php).
  • Notice: Trying to get property of non-object in include() (line 89 of node--products.tpl.php).

Line 89 is:
<li> <a href="/node/<?php print $related['target_id']; ?>">Item # <?php print $related['entity']->title; ?></a></li>

Any suggestions?

Note: The actual referenced information displays just fine.

Comments

FranCarstens’s picture

Tickle.

FranCarstens’s picture

Issue summary: View changes

Added note.