function tripal_stock_node_insert
2.x tripal_stock.chado_node.inc | tripal_stock_node_insert($node) |
3.x tripal_stock.chado_node.inc | tripal_stock_node_insert($node) |
Implements hook_node_insert(). Acts on all content types.
Related topics
File
- tripal_stock/
includes/ tripal_stock.chado_node.inc, line 863 - Stock Node Functionality
Code
function tripal_stock_node_insert($node) {
// set the URL path after inserting. We do it here because we do not
// know the stock_id in the presave
switch ($node->type) {
case 'chado_stock':
// We still don't have a fully loaded node object in this hook. Therefore,
// we need to simulate one so that the right values are available for
// the URL to be determined.
$stock_id = chado_get_id_from_nid('stock', $node->nid);
$stock = chado_generate_var('stock', array('stock_id' => $stock_id));
$stock = chado_expand_var($stock, 'field', 'stock.uniquename');
$stock = chado_expand_var($stock, 'field', 'stock.description');
$node->stock = $stock;
// Set the Title.
$node->title = chado_get_node_title($node);
// Now use the API to set the path.
chado_set_node_url($node);
break;
}
}