Skip to content

Instantly share code, notes, and snippets.

@djs070
Created December 20, 2012 06:14
Show Gist options
  • Save djs070/4343278 to your computer and use it in GitHub Desktop.
Save djs070/4343278 to your computer and use it in GitHub Desktop.
<div class="related-content">
<?php
$related_products_query = new EntityFieldQuery();
$related_products = $related_products_query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'product')
->propertyCondition('status', 1)
->fieldCondition('field_related_products', 'target_id', $node->nid)
->execute();
if (is_array($related_products) && isset($related_products['node'])) {
$related_nids = array_keys($related_products['node']);
}
?>
<?php if(!empty($content['field_related_products']) || !empty($related_nids)): ?>
<div class="related-thumbnails">
<h3 class="field-label">Related Products</h3>
<hr class="field-label-divider" />
<?php print render($content['field_related_products']); ?>
<?php
if (isset($related_nids)) {
foreach ($related_nids as $related_nid) {
print drupal_render(node_view(node_load($related_nid), 'teaser'));
}
}
?>
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment