Skip to content

Instantly share code, notes, and snippets.

@imr
Created April 26, 2012 12:46
Show Gist options
  • Save imr/2499324 to your computer and use it in GitHub Desktop.
Save imr/2499324 to your computer and use it in GitHub Desktop.
Drupal 6 code needing conversion to Drupal 7
<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2))) {
$node = node_load(arg(1));
if ($node->field_related_msds[0]['nid']) {
foreach ($node->field_related_msds as $msds_node_reference) {
$msds_node = node_load($msds_node_reference['nid']);
echo theme('filefield_file', $msds_node->field_msds[0]);
}
} else {
echo "none posted for this product.";
}
}
?>
Found this to work in Drupal 7:
<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2))) {
$node = node_load(arg(1));
if (count($node->field_related_msds)) {
foreach ($node->field_related_msds['und'] as $msds_node_reference) {
$msds_node = node_load($msds_node_reference['nid']);
$the_field = field_view_field('node', $msds_node, 'field_msds', array('label' => 'hidden'));
echo render($the_field);
}
} else {
echo "none posted for this product.";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment