function tripal_pub_set_pub_url

2.x tripal_pub.admin.inc tripal_pub_set_pub_url($node, $pub_id)
3.x tripal_pub.admin.inc tripal_pub_set_pub_url($node, $pub_id)
1.x tripal_pub.admin.inc tripal_pub_set_pub_url($node, $pub_id)

Set the URL for a publication

Parameters

$node: The publication node from pub_load().

$pub_id: The chado pub_id of the publication to set the url for

Return value

The url alias set

Related topics

3 calls to tripal_pub_set_pub_url()
tripal_pub_node_insert in tripal_pub/includes/tripal_pub.chado_node.inc
Implements hook_node_insert(). Acts on all content types.
tripal_pub_node_load in tripal_pub/includes/tripal_pub.chado_node.inc
Implements hook_node_load(). Acts on all content types.
tripal_pub_node_update in tripal_pub/includes/tripal_pub.chado_node.inc
Implements hook_node_update(). Acts on all content types.

File

tripal_pub/includes/tripal_pub.admin.inc, line 212
Administration of publications

Code

function tripal_pub_set_pub_url($node, $pub_id) {

  $node_url = "node/$node->nid";
  $url_alias = "pub/$pub_id";

  // remove any previous alias
  db_query("DELETE FROM {url_alias} WHERE source = :source", array(':source' => $node_url));
  // add the new alias
  $path_alias = array("source" => $node_url, "alias" => $url_alias);
  path_save($path_alias);

  return $url_alias;
}