Procházet zdrojové kódy

Chado Node API: Added the ability to set titles to all node types :)

Lacey Sanderson před 11 roky
rodič
revize
e5370d767c

+ 19 - 0
tripal_analysis/includes/tripal_analysis.admin.inc

@@ -60,6 +60,25 @@ function tripal_analysis_admin() {
   // has a setting will be added.
   $form = array();
 
+  // If your module is using the Chado Node: Title & Path API to allow custom titles
+  // for your node type then you need to add the configuration form for this functionality.
+  $details = array(
+    'module' => 'tripal_analysis',       // the name of the MODULE implementing the content type
+    'content_type' => 'chado_analysis',   // the name of the content type
+      // An array of options to use under "Page Titles"
+      // the key should be the token and the value should be the human-readable option
+    'options' => array(
+      '[analysis.name]' => 'Analysis Name Only',
+        // there should always be one options matching the unique constraint.
+      '[analysis.name] ([analysis.sourcename]) [analysis.program] version [analysis.programversion]' => 'Unique Contraint: Includes the name, source and program name/version'
+    ),
+    // the token indicating the unique constraint in the options array
+    'unique_option' => '[analysis.name] ([analysis.sourcename]) [analysis.program] version [analysis.programversion]'
+  );
+  // This call adds the configuration form to your current form
+  // This sub-form handles it's own validation & submit
+  chado_add_admin_form_set_title($form, $form_state, $details);
+
   // Add sub-module settings. Pull all sub-module information from
   // {tripal_analysis} table
   $sql = "SELECT modulename FROM {tripal_analysis}";

+ 58 - 9
tripal_analysis/includes/tripal_analysis.chado_node.inc

@@ -47,7 +47,7 @@ function tripal_analysis_node_info() {
  */
 function chado_analysis_form($node, &$form_state) {
   $form = array();
-  
+
   // Default values can come in the following ways:
   //
   // 1) as elements of the $node object.  This occurs when editing an existing analysis
@@ -87,7 +87,7 @@ function chado_analysis_form($node, &$form_state) {
     $timeexecuted   = $analysis->timeexecuted;
     $description    = $analysis->description;
     $analysis_type  = $node->type;
-    
+
 
     // set the analysis_id in the form
     $form['analysis_id'] = array(
@@ -231,7 +231,7 @@ function chado_analysis_form($node, &$form_state) {
   /*
   // get node types from analysis extension modules
   $sql = "SELECT modulename FROM {tripal_analysis}";
-  $modules = db_query($sql);  
+  $modules = db_query($sql);
   $node_types = array();
   $node_types['chado_analysis'] = 'Analysis';
   foreach($modules as $module) {
@@ -240,7 +240,7 @@ function chado_analysis_form($node, &$form_state) {
       $node_types[$mtypename] = $mtype['name'];
     }
   }
-  
+
   if (count($node_types) > 0) {
     $form['analysis_type'] = array(
       '#title'         => t('Analysis Type'),
@@ -251,7 +251,7 @@ function chado_analysis_form($node, &$form_state) {
       '#options'       => $node_types,
     );
   } */
-  
+
   // Properties Form
   // ----------------------------------
   $instructions = t('To add additional properties to the drop down. ' . l("Add terms to the analysis_property vocabulary", "admin/tripal/chado/tripal_cv/cvterm/add") . ".");
@@ -310,7 +310,7 @@ function tripal_analysis_validate($node, $form, &$form_state) {
   $node->sourcename = trim($node->sourcename);
   $node->sourceversion = trim($node->sourceversion);
   $node->sourceuri = trim($node->sourceuri);
-  
+
   // Validating for an update
   if (!is_null($node->nid)) {
 
@@ -566,7 +566,7 @@ function chado_analysis_load($nodes) {
     if (!$analysis_id) {
       continue;
     }
-    
+
     // build the analysis variable
     $values = array('analysis_id' => $analysis_id);
     $analysis = chado_generate_var('analysis', $values);
@@ -574,6 +574,9 @@ function chado_analysis_load($nodes) {
     // add in the description field
     $analysis = chado_expand_var($analysis, 'field', 'analysis.description');
     $nodes[$nid]->analysis = $analysis;
+
+    // Now get the title
+    $node->title = chado_get_node_title($node);
   }
 }
 
@@ -606,7 +609,7 @@ function chado_analysis_node_access($node, $op, $account) {
   if (is_object($node)) {
     $node_type = $node->type;
   }
-  
+
   if($node_type == 'chado_analysis') {
     if ($op == 'create') {
       if (!user_access('create chado_analysis content', $account)) {
@@ -694,7 +697,7 @@ function tripal_analysis_node_presave($node) {
     if ($name) {
       $node->title = $name;
     }
-    // reset the type 
+    // reset the type
     //$node->type = $node->analysis_type;
   }
   else if (property_exists($node, 'analysis')) {
@@ -710,3 +713,49 @@ function tripal_analysis_node_presave($node) {
     //$node->type = $node->analysis_type;
   }
 }
+
+/**
+ * Implements hook_node_insert().
+ * Acts on all content types.
+ *
+ * @ingroup tripal_analysis
+ */
+function tripal_analysis_node_insert($node) {
+
+  switch ($node->type) {
+    case 'chado_analysis':
+
+      // Now get the title
+      $node->title = chado_get_node_title($node);
+
+      break;
+  }
+}
+
+/**
+ * Implements hook_node_update().
+ * Acts on all content types.
+ *
+ * @ingroup tripal_analysis
+ */
+function tripal_analysis_node_update($node) {
+
+  switch ($node->type) {
+    case 'chado_analysis':
+
+      // Now get the title
+      $node->title = chado_get_node_title($node);
+
+      break;
+  }
+}
+
+/**
+ * Implements [content_type]_chado_node_default_title_format().
+ *
+ * Defines a default title format for the Chado Node API to set the titles on
+ * Chado Analysis nodes based on chado fields.
+ */
+function chado_analysis_chado_node_default_title_format() {
+  return '[analysis.name]';
+}

+ 17 - 2
tripal_contact/includes/tripal_contact.admin.inc

@@ -50,9 +50,24 @@ function tripal_contact_admin_contact_view() {
 function tripal_contact_admin() {
   $form = array();
 
-  $form['nothing'] = array(
-    '#markup' => t('There are currently no settings to configure.')
+  // If your module is using the Chado Node: Title & Path API to allow custom titles
+  // for your node type then you need to add the configuration form for this functionality.
+  $details = array(
+    'module' => 'tripal_contact',       // the name of the MODULE implementing the content type
+    'content_type' => 'chado_contact',   // the name of the content type
+      // An array of options to use under "Page Titles"
+      // the key should be the token and the value should be the human-readable option
+    'options' => array(
+      '[contact.name]' => 'Contact Name Only',
+        // there should always be one options matching the unique constraint.
+      '[contact.name]' => 'Unique Contraint: The name of the contact'
+    ),
+    // the token indicating the unique constraint in the options array
+    'unique_option' => '[contact.name]'
   );
+  // This call adds the configuration form to your current form
+  // This sub-form handles it's own validation & submit
+  chado_add_admin_form_set_title($form, $form_state, $details);
 
   return system_settings_form($form);
 }

+ 59 - 10
tripal_contact/includes/tripal_contact.chado_node.inc

@@ -181,7 +181,7 @@ function chado_contact_form(&$node, $form_state) {
   $prop_cv = tripal_get_default_cv('contactprop', 'type_id');
   $cv_id = $prop_cv ? $prop_cv->cv_id : NULL;
   $select_options = array();
-  
+
   // the Tripal contact vocabulary is heirarchical so if that vocab is default we
   // want to use the subset of terms not under the type 'Contact Type' for our
   // properties list.
@@ -220,7 +220,7 @@ function chado_contact_form(&$node, $form_state) {
   // RELATIONSHIPS FORM
   //---------------------------------------------
   $relationship_cv = tripal_get_default_cv('contact_relationship', 'type_id');
-  $cv_id = $relationship_cv ? $relationship_cv->cv_id : NULL;  
+  $cv_id = $relationship_cv ? $relationship_cv->cv_id : NULL;
   $details = array(
     'relationship_table' => 'contact_relationship', // the name of the _relationship table
     'base_table' => 'contact',                      // the name of your chado base table
@@ -257,8 +257,8 @@ function chado_contact_validate($node, $form, &$form_state) {
   // remove surrounding white-space on submitted values
   $node->contactname    = trim($node->contactname);
   $node->description    = trim($node->description);
-  
-  
+
+
   // Validating for an update
   if (!is_null($node->nid)) {
     // get the existing node
@@ -314,12 +314,12 @@ function chado_contact_validate($node, $form, &$form_state) {
  * @ingroup tripal_contact
  */
 function chado_contact_node_access($node, $op, $account ) {
-  
+
   $node_type = $node;
   if (is_object($node)) {
     $node_type = $node->type;
   }
-  
+
   if($node_type == 'chado_contact') {
     if ($op == 'create') {
       if (!user_access('create chado_contact content', $account)) {
@@ -327,7 +327,7 @@ function chado_contact_node_access($node, $op, $account ) {
       }
       return NODE_ACCESS_ALLOW;
     }
-  
+
     if ($op == 'update') {
       if (!user_access('edit chado_contact content', $account)) {
         return NODE_ACCESS_DENY;
@@ -379,7 +379,7 @@ function chado_contact_insert($node) {
     $contact = chado_insert_record('contact', $values);
     if (!$contact) {
       drupal_set_message(t('Unable to add contact.', 'warning'));
-      tripal_report_error('tripal_contact', TRIPAL_ERROR, 
+      tripal_report_error('tripal_contact', TRIPAL_ERROR,
         'Insert contact: Unable to create contact where values: %values',
         array('%values' => print_r($values, TRUE)));
       return;
@@ -455,7 +455,7 @@ function chado_contact_update($node) {
   $status = chado_update_record('contact', $match, $values);
   if (!$status) {
     drupal_set_message("Error updating contact", "error");
-    tripal_report_error('tripal_contact', TRIPAL_ERROR, 
+    tripal_report_error('tripal_contact', TRIPAL_ERROR,
       "Error updating contact", array());
     return;
   }
@@ -506,7 +506,7 @@ function chado_contact_load($nodes) {
     if (!$contact_id) {
       continue;
     }
-    
+
     // get the contact
     $values = array('contact_id' => $contact_id);
     $contact = chado_generate_var('contact', $values);
@@ -531,6 +531,9 @@ function chado_contact_load($nodes) {
     }
 
     $nodes[$nid]->contact = $contact;
+
+    // Now get the title
+    $node->title = chado_get_node_title($node);
   }
 }
 
@@ -631,4 +634,50 @@ function tripal_contact_node_presave($node) {
       }
       break;
   }
+}
+
+/**
+ * Implements hook_node_insert().
+ * Acts on all content types.
+ *
+ * @ingroup tripal_contact
+ */
+function tripal_contact_node_insert($node) {
+
+  switch ($node->type) {
+    case 'chado_contact':
+
+      // Now get the title
+      $node->title = chado_get_node_title($node);
+
+      break;
+  }
+}
+
+/**
+ * Implements hook_node_update().
+ * Acts on all content types.
+ *
+ * @ingroup tripal_contact
+ */
+function tripal_contact_node_update($node) {
+
+  switch ($node->type) {
+    case 'chado_contact':
+
+      // Now get the title
+      $node->title = chado_get_node_title($node);
+
+      break;
+  }
+}
+
+/**
+ * Implements [content_type]_chado_node_default_title_format().
+ *
+ * Defines a default title format for the Chado Node API to set the titles on
+ * Chado contact nodes based on chado fields.
+ */
+function chado_contact_chado_node_default_title_format() {
+  return '[contact.name]';
 }

+ 16 - 2
tripal_featuremap/includes/tripal_featuremap.admin.inc

@@ -47,9 +47,23 @@ function tripal_featuremap_admin_featuremaps_listing() {
 function tripal_featuremap_admin() {
   $form = array();
 
-  $form['nothing'] = array(
-    '#markup' => t('There are currently no settings to configure.')
+  // If your module is using the Chado Node: Title & Path API to allow custom titles
+  // for your node type then you need to add the configuration form for this functionality.
+  $details = array(
+    'module' => 'tripal_featuremap',       // the name of the MODULE implementing the content type
+    'content_type' => 'chado_featuremap',   // the name of the content type
+      // An array of options to use under "Page Titles"
+      // the key should be the token and the value should be the human-readable option
+    'options' => array(
+        // there should always be one options matching the unique constraint.
+      '[featuremap.name]' => 'Unique Contraint: The name of the map'
+    ),
+    // the token indicating the unique constraint in the options array
+    'unique_option' => '[featuremap.name]'
   );
+  // This call adds the configuration form to your current form
+  // This sub-form handles it's own validation & submit
+  chado_add_admin_form_set_title($form, $form_state, $details);
 
   return system_settings_form($form);
 }

+ 49 - 0
tripal_featuremap/includes/tripal_featuremap.chado_node.inc

@@ -426,6 +426,9 @@ function chado_featuremap_load($nodes) {
     $featuremap = chado_expand_var($featuremap, 'field', 'featuremap.description');
 
     $nodes[$nid]->featuremap = $featuremap;
+
+    // Now get the title
+    $node->title = chado_get_node_title($node);
   }
 
 }
@@ -536,4 +539,50 @@ function tripal_featuremap_node_view($node, $view_mode, $langcode) {
       }
       break;
   }
+}
+
+/**
+ * Implements hook_node_insert().
+ * Acts on all content types.
+ *
+ * @ingroup tripal_featuremap
+ */
+function tripal_featuremap_node_insert($node) {
+
+  switch ($node->type) {
+    case 'chado_featuremap':
+
+      // Now get the title
+      $node->title = chado_get_node_title($node);
+
+      break;
+  }
+}
+
+/**
+ * Implements hook_node_update().
+ * Acts on all content types.
+ *
+ * @ingroup tripal_featuremap
+ */
+function tripal_featuremap_node_update($node) {
+
+  switch ($node->type) {
+    case 'chado_featuremap':
+
+      // Now get the title
+      $node->title = chado_get_node_title($node);
+
+      break;
+  }
+}
+
+/**
+ * Implements [content_type]_chado_node_default_title_format().
+ *
+ * Defines a default title format for the Chado Node API to set the titles on
+ * Chado featuremap nodes based on chado fields.
+ */
+function chado_featuremap_chado_node_default_title_format() {
+  return '[featuremap.name]';
 }

+ 17 - 2
tripal_library/includes/tripal_library.admin.inc

@@ -47,9 +47,24 @@ function tripal_library_admin_libraries_listing() {
 function tripal_library_admin() {
   $form = array();
 
-  $form['nothing'] = array(
-    '#markup' => t('There are currently no settings to configure.')
+  // If your module is using the Chado Node: Title & Path API to allow custom titles
+  // for your node type then you need to add the configuration form for this functionality.
+  $details = array(
+    'module' => 'tripal_library',       // the name of the MODULE implementing the content type
+    'content_type' => 'chado_library',   // the name of the content type
+      // An array of options to use under "Page Titles"
+      // the key should be the token and the value should be the human-readable option
+    'options' => array(
+      '[library.name]' => 'Library Name Only',
+        // there should always be one options matching the unique constraint.
+      '[library.name], [library.uniquename] ([library.type_id>cvterm.name]) [library.organism_id>organism.genus] [library.organism_id>organism.species]' => 'Unique Contraint: Includes the name, type and organism scientific name'
+    ),
+    // the token indicating the unique constraint in the options array
+    'unique_option' => '[library.name], [library.uniquename] ([library.type_id>cvterm.name]) [library.organism_id>organism.genus] [library.organism_id>organism.species]'
   );
+  // This call adds the configuration form to your current form
+  // This sub-form handles it's own validation & submit
+  chado_add_admin_form_set_title($form, $form_state, $details);
 
   return system_settings_form($form);
 }

+ 49 - 0
tripal_library/includes/tripal_library.chado_node.inc

@@ -394,6 +394,9 @@ function chado_library_load($nodes) {
     $library = chado_expand_var($library, 'field', 'library.uniquename');
 
     $nodes[$nid]->library = $library;
+
+    // Now get the title
+    $node->title = chado_get_node_title($node);
   }
 }
 
@@ -578,3 +581,49 @@ function tripal_library_node_presave($node) {
       break;
   }
 }
+
+/**
+ * Implements hook_node_insert().
+ * Acts on all content types.
+ *
+ * @ingroup tripal_library
+ */
+function tripal_library_node_insert($node) {
+
+  switch ($node->type) {
+    case 'chado_library':
+
+      // Now get the title
+      $node->title = chado_get_node_title($node);
+
+      break;
+  }
+}
+
+/**
+ * Implements hook_node_update().
+ * Acts on all content types.
+ *
+ * @ingroup tripal_library
+ */
+function tripal_library_node_update($node) {
+
+  switch ($node->type) {
+    case 'chado_library':
+
+      // Now get the title
+      $node->title = chado_get_node_title($node);
+
+      break;
+  }
+}
+
+/**
+ * Implements [content_type]_chado_node_default_title_format().
+ *
+ * Defines a default title format for the Chado Node API to set the titles on
+ * Chado library nodes based on chado fields.
+ */
+function chado_library_chado_node_default_title_format() {
+  return '[library.name], [library.uniquename] ([library.type_id>cvterm.name])';
+}

+ 17 - 2
tripal_organism/includes/tripal_organism.admin.inc

@@ -48,9 +48,24 @@ function tripal_organism_admin() {
 
   $form = array();
 
-  $form['nothing'] = array(
-    '#markup' => t('There are currently no settings to configure.')
+  // If your module is using the Chado Node: Title & Path API to allow custom titles
+  // for your node type then you need to add the configuration form for this functionality.
+  $details = array(
+    'module' => 'tripal_organism',       // the name of the MODULE implementing the content type
+    'content_type' => 'chado_organism',   // the name of the content type
+      // An array of options to use under "Page Titles"
+      // the key should be the token and the value should be the human-readable option
+    'options' => array(
+      '[organism.name]' => 'Organism Name Only',
+        // there should always be one options matching the unique constraint.
+      '[organism.genus] [organism.species]' => 'Unique Contraint: The scientific name'
+    ),
+    // the token indicating the unique constraint in the options array
+    'unique_option' => '[organism.genus] [organism.species]'
   );
+  // This call adds the configuration form to your current form
+  // This sub-form handles it's own validation & submit
+  chado_add_admin_form_set_title($form, $form_state, $details);
 
   return system_settings_form($form);
 }

+ 49 - 0
tripal_organism/includes/tripal_organism.chado_node.inc

@@ -501,6 +501,9 @@ function chado_organism_load($nodes) {
     // add in the description field
     $organism = chado_expand_var($organism, 'field', 'organism.comment');
     $nodes[$nid]->organism = $organism;
+
+    // Now get the title
+    $node->title = chado_get_node_title($node);
   }
 }
 
@@ -565,3 +568,49 @@ function tripal_organism_node_view($node, $view_mode, $langcode) {
       break;
   }
 }
+
+/**
+ * Implements hook_node_insert().
+ * Acts on all content types.
+ *
+ * @ingroup tripal_organism
+ */
+function tripal_organism_node_insert($node) {
+
+  switch ($node->type) {
+    case 'chado_organism':
+
+      // Now get the title
+      $node->title = chado_get_node_title($node);
+
+      break;
+  }
+}
+
+/**
+ * Implements hook_node_update().
+ * Acts on all content types.
+ *
+ * @ingroup tripal_organism
+ */
+function tripal_organism_node_update($node) {
+
+  switch ($node->type) {
+    case 'chado_organism':
+
+      // Now get the title
+      $node->title = chado_get_node_title($node);
+
+      break;
+  }
+}
+
+/**
+ * Implements [content_type]_chado_node_default_title_format().
+ *
+ * Defines a default title format for the Chado Node API to set the titles on
+ * Chado organism nodes based on chado fields.
+ */
+function chado_organism_chado_node_default_title_format() {
+  return '[organism.genus] [organism.species]';
+}

+ 19 - 0
tripal_project/includes/tripal_project.admin.inc

@@ -46,6 +46,25 @@ function tripal_project_admin_project_view() {
 function tripal_project_admin($form, $form_state) {
   $form = array();
 
+  // If your module is using the Chado Node: Title & Path API to allow custom titles
+  // for your node type then you need to add the configuration form for this functionality.
+  $details = array(
+    'module' => 'tripal_project',       // the name of the MODULE implementing the content type
+    'content_type' => 'chado_project',   // the name of the content type
+      // An array of options to use under "Page Titles"
+      // the key should be the token and the value should be the human-readable option
+    'options' => array(
+      '[project.name]' => 'project Name Only',
+        // there should always be one options matching the unique constraint.
+      '[project.name]' => 'Unique Contraint: The project name'
+    ),
+    // the token indicating the unique constraint in the options array
+    'unique_option' => '[project.name]'
+  );
+  // This call adds the configuration form to your current form
+  // This sub-form handles it's own validation & submit
+  chado_add_admin_form_set_title($form, $form_state, $details);
+  
   // project URL PATHS
   $form['url'] = array(
     '#type' => 'fieldset',

+ 22 - 1
tripal_project/includes/tripal_project.chado_node.inc

@@ -401,6 +401,10 @@ function chado_project_load($nodes) {
     $project = chado_generate_var('project', $values);
 
     $nodes[$nid]->project = $project;
+
+    // Now get the title
+    $node->title = chado_get_node_title($node);
+      
   }
 
 }
@@ -521,6 +525,9 @@ function tripal_project_node_insert($node) {
   switch ($node->type) {
     case 'chado_project':
 
+      // Now get the title
+      $node->title = chado_get_node_title($node);
+      
       // on an insert we need to add the project_id to the node object
       // so that the tripal_project_get_project_url function can set the URL properly
       $node->project_id = chado_get_id_from_nid('project', $node->nid);
@@ -547,6 +554,10 @@ function tripal_project_node_update($node) {
   // add items to other nodes, build index and search results
   switch ($node->type) {
     case 'chado_project':
+
+      // Now get the title
+      $node->title = chado_get_node_title($node);
+      
       // remove any previous alias
       db_query("DELETE FROM {url_alias} WHERE source = :source", array(':source' => "node/$node->nid"));
 
@@ -691,4 +702,14 @@ function tripal_project_set_urls($na = NULL, $job = NULL) {
     watchdog_exception('tripal_project', $e);
     watchdog('trp-seturl', "Failed Removing URL Alias: %src", array('%src' => $src), WATCHDOG_ERROR);
   }
-}
+}
+
+/**
+ * Implements [content_type]_chado_node_default_title_format().
+ *
+ * Defines a default title format for the Chado Node API to set the titles on
+ * Chado project nodes based on chado fields.
+ */
+function chado_project_chado_node_default_title_format() {
+  return '[project.name]';
+}

+ 19 - 0
tripal_pub/includes/tripal_pub.admin.inc

@@ -47,6 +47,25 @@ function tripal_pub_admin_pub_view() {
 function tripal_pub_admin() {
   $form = array();
 
+  // If your module is using the Chado Node: Title & Path API to allow custom titles
+  // for your node type then you need to add the configuration form for this functionality.
+  $details = array(
+    'module' => 'tripal_pub',       // the name of the MODULE implementing the content type
+    'content_type' => 'chado_pub',   // the name of the content type
+      // An array of options to use under "Page Titles"
+      // the key should be the token and the value should be the human-readable option
+    'options' => array(
+      '[pub.title]' => 'Publication Title',
+        // there should always be one options matching the unique constraint.
+      '[pub.uniquename]' => 'Unique Contraint: Citation of the Publication.'
+    ),
+    // the token indicating the unique constraint in the options array
+    'unique_option' => '[pub.uniquename]'
+  );
+  // This call adds the configuration form to your current form
+  // This sub-form handles it's own validation & submit
+  chado_add_admin_form_set_title($form, $form_state, $details);
+  
   // -----------------------------------------
   // add in the fields for selecting which fields are used when search for pubs
   $form['searching'] = array(

+ 21 - 0
tripal_pub/includes/tripal_pub.chado_node.inc

@@ -963,6 +963,9 @@ function chado_pub_load($nodes) {
     // set the URL path
     $nodes[$nid]->path = "pub/$pub_id";
     $nodes[$nid]->pub = $pub;
+
+    // Now get the title
+    $node->title = chado_get_node_title($node);
   }
 }
 
@@ -1088,6 +1091,10 @@ function tripal_pub_node_view($node, $view_mode, $langcode) {
 function tripal_pub_node_insert($node) {
 
   if ($node->type == 'chado_pub') {
+
+    // Now get the title
+    $node->title = chado_get_node_title($node);
+      
     $pub_id = chado_get_id_from_nid('pub', $node->nid);
     tripal_pub_set_pub_url($node, $pub_id);
   }
@@ -1132,6 +1139,10 @@ function tripal_pub_node_load($nodes, $types) {
 function tripal_pub_node_update($node) {
 
   if ($node->type == 'chado_pub') {
+
+    // Now get the title
+    $node->title = chado_get_node_title($node);
+      
     $pub_id = chado_get_id_from_nid('pub', $node->nid);
     tripal_pub_set_pub_url($node, $pub_id);
   }
@@ -1160,3 +1171,13 @@ function tripal_pub_node_presave($node) {
       break;
   }
 }
+
+/**
+ * Implements [content_type]_chado_node_default_title_format().
+ *
+ * Defines a default title format for the Chado Node API to set the titles on
+ * Chado pub nodes based on chado fields.
+ */
+function chado_pub_chado_node_default_title_format() {
+  return '[pub.title]';
+}