Browse Source

Made documentation changes to Titles & Path API

Stephen Ficklin 11 years ago
parent
commit
d4b0a1eb19

+ 1 - 1
tripal_core/api/tripal_core.DEPRECATED.inc

@@ -812,7 +812,7 @@ function tripal_mviews_action($op, $mview_id, $redirect = FALSE) {
     );
 
     //New API Function
-    return tripal_add_populate_mview($mview_id, $redirect);
+    return tripal_add_job_populate_mview($mview_id, $redirect);
   }
   if ($op == 'delete') {
     tripal_report_error(

+ 35 - 9
tripal_core/api/tripal_core.chado_nodes.title_and_path.inc

@@ -6,13 +6,42 @@
  *
  * TITLES
  * ====================================
- * There are two steps to implement the ability to set custom titles for your node type:
- * 1) Add the "Set Page Titles" Form to your admin settings form
+ * There are two steps to implement the ability to set custom titles for the node type:
+ * 1) Add the 'chado_node_api' elements to the hook_node_info function().  These values
+ *    define the name of the base table and how to refer to nodes in singular and plural.
+ *    There are additional paramaters that can be added to the 'chado_node_api' for 
+ *    syncing nodes (see documentation for the chado_node_sync_form() function for additional
+ *    options.
  * @code
-    // If your module is using the Chado Node: Title & Path API to allow custom titles
+  function modulename_node_info() {
+    return array(
+      'chado_example' => array(
+        'name' => t('example'),
+        'base' => 'chado_example',
+        'description' => t('A Chado example is a collection of material that can be sampled and have experiments performed on it.'),
+        'has_title' => TRUE,
+        'locked' => TRUE,
+
+        // this is what differs from the regular Drupal-documented hook_node_info()
+        'chado_node_api' => array(
+          'base_table' => 'example',            // the name of the chado base table
+          'hook_prefix' => 'chado_example',     // usually the name of the node type
+          'record_type_title' => array(
+            'singular' => t('Example'),         // Singular human-readable title
+            'plural' => t('Examples')           // Plural human-readable title
+          ),
+        )
+      ),
+    );
+  }
+ * @endcode
+ * 
+ * 2) Add the "Set Page Titles" Form to the admin settings form
+ * @code
+    // If the 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_example',       // the name of the MODULE implementing the content type
+      'module' => 'tripal_example',        // the name of the MODULE implementing the content type
       'content_type' => 'chado_example',   // 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
@@ -32,14 +61,13 @@
     chado_add_admin_form_set_title($form, $form_state, $details);
  * @endcode
  *
- * 2) Use chado_get_node_title($node) where ever you want the title for your node. This
+ * 3) Use chado_get_node_title($node) where ever you want the title for your node. This
  *    should be done in hook_load(), hook_node_insert(), hook_node_update(). The reason you
  *    set the title in the node_action hooks, which act on all nodes, is because at that
  *    point you have the generic loaded node.
  * @code
   function tripal_example_load($nodes) {
 
-    $new_nodes = array();
     foreach ($nodes as $nid => $node) {
 
       // Add all of the custom content for your node type.
@@ -48,10 +76,8 @@
       // Now get the title
       $node->title = chado_get_node_title($node);
 
-      $new_nodes[$nid] = $node;
+      $nodes[$nid] = $node;
     }
-
-    return $new_nodes;
   }
  * @endcode
  *

+ 3 - 3
tripal_cv/api/tripal_cv.DEPRECATED.inc

@@ -326,9 +326,9 @@ function tripal_cv_submit_obo_job($obo_id = NULL, $obo_name = NULL, $obo_url = N
   return tripal_submit_obo_job(
     array(
       'obo_id' => $obo_id,
-      'name' => $obo_name,
-      'url' => $obo_url,
-      'file' => $obo_file
+      'name'   => $obo_name,
+      'url'    => $obo_url,
+      'file'   => $obo_file
     )
   );
 }

+ 2 - 2
tripal_example/includes/tripal_example.chado_node.inc

@@ -578,8 +578,8 @@ function chado_example_load($nodes) {
     // If your module is using the Chado Node: Title & Path API to allow custom titles
     // for your node type. Every time you want the title of the node, you need to use the
     // following API function:
-    $example->title = chado_get_node_title($node);
-
+    $node->title = chado_get_node_title($node);
+    
     // add the new example object to this node.
     $nodes[$nid]->example = $example;
   }