function tripal_pub_node_load

2.x tripal_pub.chado_node.inc tripal_pub_node_load($nodes, $types)
3.x tripal_pub.chado_node.inc tripal_pub_node_load($nodes, $types)

Implements hook_node_load(). Acts on all content types.

We want the publications to always have a URL of http://[base url]/pub/[pub id] where [pub id] is the Chado publication ID. This will allow for easy linking into the publication without needing to know the node. Of course if you know the node that will still work too (e.g. http://[base url]/node/[node id] so the nodeapi function ensures that the URL path is set after insert or update of the node and when the node is loaded if it hasn't yet been set.

Related topics

File

legacy/tripal_pub/includes/tripal_pub.chado_node.inc, line 1188
Implements Drupal Node hooks to create the chado_analysis node content type.

Code

function tripal_pub_node_load($nodes, $types) {
  if (count(array_intersect(array('chado_pub'), $types))) {
    foreach ($nodes as $nid => $node) {
      if ($node->type == 'chado_pub' and !drupal_lookup_path('alias', 'node/' . $nid)) {
        $pub_id = chado_get_id_from_nid('pub', $node->nid);
        $path = tripal_pub_set_pub_url($node, $pub_id);
      }
    }
  }
}