tripal_example.chado_node.inc 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. <?php
  2. /**
  3. * @file
  4. * This file should contain all Drupal hooks for interacting with nodes.
  5. *
  6. */
  7. /**
  8. * Implementation of hook_node_info(). This hook provides information to drupal
  9. * about any node types that are being created by this module. If your module
  10. * does not create any node types then this function is not required.
  11. *
  12. * @ingroup tripal_example
  13. */
  14. function tripal_example_node_info() {
  15. $nodes = array();
  16. //$nodes['chado_example'] = array(
  17. // 'name' => t('Example'),
  18. // 'base' => 'chado_example',
  19. // 'description' => t('A example from the chado database'),
  20. // 'has_title' => TRUE,
  21. // 'locked' => TRUE
  22. // This section of the node type array specifies how Tripal will sync the node
  23. // types with data in Chado. When Drupal creates a node it has no way of
  24. // coordinating which node belongs to which record in Chado. Therefore,
  25. // Tripal maintains tables in the Drupal schema that maps Drupal nodes
  26. // to recrords in Chado. Syncing is the process of creating Drupal nodes
  27. // and linking them to the appropriate record.
  28. // 'chado_node_api' => array(
  29. // 'base_table' => 'example', // the base table name (e.g. feature, example, contact)
  30. // 'hook_prefix' => 'chado_example',// the node type hook prefix
  31. // 'record_type_title' => array(
  32. // 'singular' => t('Library'), // how to refer to the record
  33. // 'plural' => t('Libraries') // how to refer to the record in plurals
  34. // ),
  35. // 'sync_filters' => array(
  36. // 'type_id' => TRUE, // if the record has a type_id set to TRUE
  37. // 'organism_id' => TRUE // if the record has an organism_id set to TRUE
  38. // ),
  39. // )
  40. //);
  41. return $nodes;
  42. }
  43. /**
  44. * Implement hook_access(). This hook provides instructions to
  45. * drupal for which users can access the custom content types
  46. * created in the function above. The available permissions
  47. * are set in the chado_example_permissions() hook in the
  48. * tripal_example.module file. This hook is not needed
  49. * if no node types were defined in the hook_node_info() hook.
  50. *
  51. * @return
  52. * This function should return null if it does not specificially
  53. * deny access. This allows for other mechanisms to to deny
  54. * or reject access. If the return value is TRUE then access
  55. * is granted regardless of any other rules that might be implemented
  56. * by other modules.
  57. */
  58. function chado_example_node_access($node, $op, $account) {
  59. $node_type = $node;
  60. if (is_object($node)) {
  61. $node_type = $node->type;
  62. }
  63. if($node_type == 'chado_example') {
  64. if ($op == 'create') {
  65. if (!user_access('create chado_example content', $account)) {
  66. return NODE_ACCESS_DENY;
  67. }
  68. return NODE_ACCESS_ALLOW;
  69. }
  70. if ($op == 'update') {
  71. if (!user_access('edit chado_example content', $account)) {
  72. return NODE_ACCESS_DENY;
  73. }
  74. }
  75. if ($op == 'delete') {
  76. if (!user_access('delete chado_example content', $account)) {
  77. return NODE_ACCESS_DENY;
  78. }
  79. }
  80. if ($op == 'view') {
  81. if (!user_access('access chado_example content', $account)) {
  82. return NODE_ACCESS_DENY;
  83. }
  84. }
  85. }
  86. return NODE_ACCESS_IGNORE;
  87. }
  88. /**
  89. * Implementation of hook_form() when a node type of chado_example is defined.
  90. * If a node type is not defined then this function is not needed. The table
  91. * name in chado for this example module is named 'example' so there is a
  92. * corresponding example_id in that table (similar to feature.feature_id,
  93. * contact.contact_id, etc).
  94. *
  95. * @ingroup tripal_example
  96. */
  97. function chado_example_form($node, &$form_state) {
  98. $form = array();
  99. // Default values can come in the following ways:
  100. //
  101. // 1) as elements of the $node object. This occurs when editing an existing example
  102. // 2) in the $form_state['values'] array which occurs on a failed validation or
  103. // ajax callbacks from non submit form elements
  104. // 3) in the $form_state['input'[ array which occurs on ajax callbacks from submit
  105. // form elements and the form is being rebuilt
  106. //
  107. // set form field defaults
  108. // if we are editing an existing node then the example is already part of the node
  109. if (property_exists($node, 'example')) {
  110. // $example = $node->example;
  111. // $example = chado_expand_var($example, 'field', 'example.residues');
  112. // $example_id = $example->example_id;
  113. // $uniquename = $example->uniquename;
  114. // keep track of the example id
  115. //$form['example_id'] = array(
  116. // '#type' => 'value',
  117. // '#value' => $example_id,
  118. //);
  119. }
  120. // if we are re constructing the form from a failed validation or ajax callback
  121. // then use the $form_state['values'] values
  122. if (array_key_exists('values', $form_state)) {
  123. // $uniquename = $form_state['values']['uniquename'];
  124. }
  125. // if we are re building the form from after submission (from ajax call) then
  126. // the values are in the $form_state['input'] array
  127. if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
  128. // $uniquename = $form_state['input']['uniquename'];
  129. }
  130. // add form elements here.
  131. // PROPERTIES FORM
  132. //---------------------------------------------
  133. // If there is a exampleprop table and you want to allow users to add/remove entries
  134. // from it through your node form then add this section to your own node form
  135. $details = array(
  136. 'property_table' => 'exampleprop', // the name of the prop table
  137. 'chado_id' => $example_id, // the value of example_id for this record
  138. 'cv_name' => 'example_property_types' // the cv.name of the cv governing exampleprop.type_id
  139. );
  140. // Adds the form elements to your current form
  141. chado_add_node_form_properties($form, $form_state, $details);
  142. // ADDITIONAL DBXREFS FORM
  143. //---------------------------------------------
  144. // If there is a example_dbxref table and you want to allow users to add/remove entries
  145. // from it through your node form then add this section to your own node form
  146. $details = array(
  147. 'linking_table' => 'example_dbxref', // the name of the _dbxref table
  148. 'base_foreign_key' => 'example_id', // the name of the key in your base chado table
  149. 'base_key_value' => $example_id // the value of example_id for this record
  150. );
  151. // Adds the form elements to your current form
  152. chado_add_node_form_dbxrefs($form, $form_state, $details);
  153. // RELATIONSHIPS FORM
  154. //---------------------------------------------
  155. // If there is a example_relationship table and you want to allow users to add/remove entries
  156. // from it through your node form then add this section to your own node form
  157. $details = array(
  158. 'relationship_table' => 'example_relationship', // the name of the _relationship table
  159. 'base_table' => 'example', // the name of your chado base table
  160. 'base_foreign_key' => 'example_id', // the name of the key in your base chado table
  161. 'base_key_value' => $example_id, // the value of example_id for this record
  162. 'nodetype' => 'example', // the human-readable name of your node type
  163. 'cv_name' => 'example_relationship_types' // the cv.name of the cv governing example_relationship.type_id
  164. );
  165. // Adds the form elements to your current form
  166. chado_add_node_form_relationships($form, $form_state, $details);
  167. // return the form
  168. return $form;
  169. }
  170. /**
  171. * Implementation of hook_validate
  172. *
  173. * This validation is being used for three activities:
  174. * CASE A: Update a node that exists in both drupal and chado
  175. * CASE B: Synchronizing a node from chado to drupal
  176. * CASE C: Inserting a new node that exists in niether drupal nor chado
  177. *
  178. * @param $node
  179. *
  180. *
  181. * @ingroup tripal_example
  182. */
  183. function chado_example_validate($node, $form, &$form_state) {
  184. // if this is a delete then don't validate
  185. if($node->op == 'Delete') {
  186. return;
  187. }
  188. // we are syncing if we do not have a node ID but we do have a example_id. We don't
  189. // need to validate during syncing so just skip it.
  190. if (is_null($node->nid) and property_exists($node, 'example_id') and $node->example_id != 0) {
  191. return;
  192. }
  193. // be sure to always trim text fields
  194. // $node->uniquename = trim($node->uniquename);
  195. // Validating for an update. If the 'nid' property is present in the node then
  196. // this is an update and validation can be different for updates
  197. if (property_exists($node, 'nid')) {
  198. // if there is a problem with a field then you can set an error on the form
  199. // form_set_error('uniquename', t("example update cannot proceed. The example name '$node->uniquename' is not unique for this organism. Please provide a unique name for this example."));
  200. }
  201. // Validating for an insert
  202. else {
  203. // if there is a problem with a field then you can set an error on the form
  204. // form_set_error('uniquename', t("example insert cannot proceed. The example name '$node->uniquename' already exists for this organism. Please provide a unique name for this example."));
  205. }
  206. }
  207. /**
  208. * Implementation of hook_insert(). This function is called after the
  209. * node is inserted into the database. We need it so that we can insert
  210. * appropriate fields as provided by the user into the database. And so that
  211. * we can link the new Drupal node to the data in Chado via the chado_example
  212. * linking table. We can get to this function also during "syncing".
  213. * With syncing, however, the data already exists in Chado and we do not want
  214. * to try to re-add it. But we do need to add an entry to the chado_example table
  215. * to link the Drupal node with the data in the 'example' table of Chado.
  216. *
  217. * This function is not required if the hook_node_info() does not define
  218. * any custom node types.
  219. *
  220. * @ingroup tripal_example
  221. */
  222. function chado_example_insert($node) {
  223. // be sure to always trim text fields
  224. //$node->uniquename = trim($node->uniquename);
  225. // if there is an example_id in the $node object then this must be a sync so
  226. // we can skip adding the example as it is already there, although
  227. // we do need to proceed with the rest of the insert
  228. if (!property_exists($node, 'example_id')) {
  229. // ADD TO CHADO
  230. // * Example Table *
  231. // perform the insert using the tripal_core_chado_insert function();
  232. //$values = array(
  233. // 'uniquename' => $node->uniquename,
  234. // 'residues' => $residues,
  235. //);
  236. //$example = chado_select_record('example', array('*'), $values);
  237. //if (!$example) {
  238. // drupal_set_message(t('Unable to add example.'), 'warning');
  239. // tripal_report_error('tripal_example', TRIPAL_WARNING, 'Insert example: Unable to create example where values: %values',
  240. // array('%values' => print_r($values, TRUE)));
  241. // return;
  242. //}
  243. // get the example_id for linking Drupal node with Chado data
  244. // $example_id = $example->example_id;
  245. // Only add to other chado tables if the base record was inserted properly
  246. if ($example_id > 0) {
  247. // * Properties Form *
  248. // If you implemented the properties form in chado_example_form then you need to
  249. // handle inserting these properties into your chado prop table.
  250. // $details = array(
  251. // 'property_table' => 'exampleprop', // the name of the prop table
  252. // 'base_table' => 'example', // the name of your chado base table
  253. // 'foreignkey_name' => 'example_id', // the name of the key in your base table
  254. // 'foreignkey_value' => $example_id // the value of the example_id key
  255. // );
  256. // chado_update_node_form_properties($node, $details);
  257. // * Additional DBxrefs Form *
  258. // If you implemented the dbxrefs form in chado_example_form then you need to
  259. // handle inserting these database references into your chado _dbxref table.
  260. // $details = array(
  261. // 'linking_table' => 'example_dbxref', // the name of your _dbxref table
  262. // 'foreignkey_name' => 'example_id', // the name of the key in your base table
  263. // 'foreignkey_value' => $example_id // the value of the example_id key
  264. // );
  265. // chado_update_node_form_dbxrefs($node, $details);
  266. // * Relationships Form *
  267. // If you implemented the relationships form in chado_example_form then you need to
  268. // handle inserting these relationships into your chado _relationship table.
  269. // $details = array(
  270. // 'relationship_table' => 'example_relationship', // name of the _relationship table
  271. // 'foreignkey_value' => $example_id // value of the example_id key
  272. // );
  273. // chado_update_node_form_relationships($node, $details);
  274. }
  275. }
  276. else {
  277. // the node has an example_id so get it for linking Drupal node with Chado data
  278. // $example_id = $node->example_id;
  279. }
  280. // Make sure the entry for this example doesn't already exist in the
  281. // chado_example table if it doesn't exist then we want to add it.
  282. // $check_org_id = chado_get_id_from_nid('example', $node->nid);
  283. //if (!$check_org_id) {
  284. // $record = new stdClass();
  285. // $record->nid = $node->nid;
  286. // $record->vid = $node->vid;
  287. // $record->example_id = $example_id;
  288. // drupal_write_record('chado_example', $record);
  289. //}
  290. }
  291. /**
  292. * Implementation of hook_update(). This function runs after the
  293. * node has been inserted into the Drupal schema and allows us to
  294. * update the record in Chado.
  295. *
  296. * This function is not required if the hook_node_info() does not define
  297. * any custom node types.
  298. *
  299. * @ingroup tripal_example
  300. */
  301. function chado_example_update($node) {
  302. // be sure to always trim text fields
  303. // $node->uniquename = trim($node->uniquename);
  304. // use the chado_update_record() function to update the record
  305. //$match = array(
  306. //'example_id' => $example_id,
  307. //);
  308. //$values = array(
  309. // 'uniquename' => $node->uniquename,
  310. //);
  311. //$options = array('return_record' => TRUE);
  312. //$status = chado_update_record('example', $match, $values, $options);
  313. //if (!$status) {
  314. // drupal_set_message(t('Unable to update example.'), 'warning');
  315. // tripal_report_error('tripal_example', TRIPAL_WARNING, 'Update example: Unable to update example where values: %values',
  316. // array('%values' => print_r($values, TRUE)));
  317. //}
  318. // * Properties Form *
  319. // If you implemented the properties form in chado_example_form then you need to
  320. // handle updating these properties into your chado prop table.
  321. // $details = array(
  322. // 'property_table' => 'exampleprop', // the name of the prop table
  323. // 'base_table' => 'example', // the name of your chado base table
  324. // 'foreignkey_name' => 'example_id', // the name of the key in your base table
  325. // 'foreignkey_value' => $example_id // the value of the example_id key
  326. // );
  327. // chado_update_node_form_properties($node, $details);
  328. // * Additional DBxrefs Form *
  329. // If you implemented the dbxrefs form in chado_example_form then you need to
  330. // handle updating these database references into your chado _dbxref table.
  331. // $details = array(
  332. // 'linking_table' => 'example_dbxref', // the name of your _dbxref table
  333. // 'foreignkey_name' => 'example_id', // the name of the key in your base table
  334. // 'foreignkey_value' => $example_id // the value of the example_id key
  335. // );
  336. // chado_update_node_form_dbxrefs($node, $details);
  337. // * Relationships Form *
  338. // If you implemented the relationships form in chado_example_form then you need to
  339. // handle updating these relationships into your chado _relationship table.
  340. // $details = array(
  341. // 'relationship_table' => 'example_relationship', // name of the _relationship table
  342. // 'foreignkey_value' => $example_id // value of the example_id key
  343. // );
  344. // chado_update_node_form_relationships($node, $details);
  345. }
  346. /**
  347. * Implementation of hook_delete(). This function runs after the
  348. * node has been deleted from the Drupal schema and allows us to
  349. * delete the corresponding recrod in Chado.
  350. *
  351. * This function is not required if the hook_node_info() does not define
  352. * any custom node types.
  353. *
  354. * @ingroup tripal_example
  355. */
  356. function chado_example_delete($node) {
  357. // get the example id from the node
  358. //$example_id = chado_get_id_from_nid('example', $node->nid);
  359. // if we don't have a example id for this node then this isn't a node of
  360. // type chado_example or the entry in the chado_example table was lost.
  361. if (!$example_id) {
  362. return;
  363. }
  364. // remove the entry in the chado_exapmle table linking the deleted
  365. // Drupal node with the data in chado
  366. // $sql_del = "DELETE FROM {chado_example} WHERE nid = :nid AND vid = :vid";
  367. // db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
  368. // Remove data from example tables of chado database. This will
  369. // cause a cascade delete and remove all data in referencing tables
  370. // for this example
  371. // chado_query("DELETE FROM {example} WHERE example_id = :example_id", array(':example_id' => $example_id));
  372. // inform the user that the data was deleted
  373. drupal_set_message(t("The example and all associated data were removed from Chado"));
  374. }
  375. /**
  376. * Implementation of hook_load(). This function is necessary to load
  377. * into the $node object the fields of the table form Chado. For example
  378. * for the feature table, the chado_feature_load() function adds in
  379. * a feature object which contains all of the fields and sub objects
  380. * for data in tables with foreign key relationships.
  381. *
  382. * This function is not required if the hook_node_info() does not define
  383. * any custom node types.
  384. *
  385. * @ingroup tripal_example
  386. */
  387. function chado_example_load($nodes) {
  388. // there may be multiple nodes that get passed in so we have to iterate through
  389. // them all
  390. foreach ($nodes as $nid => $node) {
  391. // find the example and add in the details
  392. //$example_id = chado_get_id_from_nid('example', $nid);
  393. // build the example variable by using the chado_generate_var() function
  394. //$values = array('example_id' => $example_id);
  395. //$example = chado_generate_var('example', $values);
  396. // for fields in the table that are of type 'text' you may want to include those
  397. // by default, the tripal_core_generate_chado_var does not include text fields as
  398. // they may be very large and including a large text field can slow the page load.
  399. // If you know a text field will never be large and it is important for the
  400. // other functions that will see the node to have access to a field you can
  401. // include it here using the chado_expand_var() function. In most
  402. // cases it is probably best to let the end-user decide if text fields should
  403. // be included by using this function in the templates.
  404. //$example = chado_expand_var($example, 'field', 'example.residues');
  405. // add the new example object to this node.
  406. //$nodes[$nid]->example = $example;
  407. }
  408. }
  409. /**
  410. * Implementation of hook_node_presave(). This node is useful for
  411. * making changes to the node prior to it being saved to the database.
  412. * One useful case for this is to set the title of a node. In some cases
  413. * such as for the organism module, the title will be set depending on
  414. * what genus and species is provided. This hook can allow the title to
  415. * be set using user supplied data before the node is saved. In practice
  416. * any change can be made to any fields in the node object.
  417. *
  418. * This function is not required. You probably won't need it if you
  419. * don't define a custom node type in the hook_node_info() function. But
  420. * it is node type agnostic, so you can use this function to change the
  421. * contents of any node regardless of it's type.
  422. *
  423. * @ingroup tripal_example
  424. */
  425. function tripal_example_node_presave($node) {
  426. /*
  427. // set the node title
  428. switch ($node->type) {
  429. case 'chado_example':
  430. // for a form submission the 'examplename' field will be set,
  431. // for a sync, we must pull from the example object
  432. if (property_exists($node, 'examplename')) {
  433. // set the title
  434. $node->title = $node->examplename;
  435. }
  436. else if (property_exists($node, 'example')) {
  437. $node->title = $node->example->name;
  438. }
  439. break;
  440. }
  441. */
  442. }
  443. /**
  444. * Implementation of hook node_insert(). This function is used
  445. * after any a node is inserted into the database. It is different
  446. * from the hook_insert() function above in that it is called after
  447. * any node is saved, regardlesss of it's type. This function is useful
  448. * for making changes to the database after a node is inserted when you
  449. * can't edit the hook_insert() function of a node not defined by this
  450. * module, or to access values of a node when have not yet been saved.
  451. * An example comes from the tripal_feature module where the URL alias
  452. * of a node cannot be set in the hook_insert() function. Therefore
  453. * the tripal_feature module uses this function to set the url path
  454. * of a newly inserted feature node.
  455. *
  456. * This function is not required. You probably won't need it if you
  457. * don't define a custom node type in the hook_node_info() function. But
  458. * it is node type agnostic, so you can use this function to do any
  459. * activity after insert of a node.
  460. *
  461. * @ingroup tripal_example
  462. */
  463. function tripal_example_node_insert($node) {
  464. // set the URL path after inserting. We do it here because we do not know the
  465. // example_id in the presave and cannot do it in the hook_insert()
  466. //switch ($node->type) {
  467. // case 'chado_example':
  468. // if (!$node->example_id) {
  469. // $sql = "SELECT * FROM {chado_example} WHERE nid = :nid";
  470. // $chado_example = db_query($sql, array(':nid' => $node->nid))->fetchObject();
  471. // $node->example_id = $chado_example->example_id;
  472. // }
  473. // // remove any previous alias
  474. // db_query("DELETE FROM {url_alias} WHERE source = :source", array(':source' => "node/$node->nid"));
  475. // // set the URL for this example page
  476. // $url_alias = tripal_example_get_example_url($node);
  477. // $path_alias = array("source" => "node/$node->nid", "alias" => $url_alias);
  478. // path_save($path_alias);
  479. // break;
  480. //}
  481. }
  482. /**
  483. * Implementation of hook node_update(). This function is used
  484. * after any a node is updated in the database. It is different
  485. * from the hook_update() function above in that it is called after
  486. * any node is updated, regardlesss of it's type. This function is useful
  487. * for making changes to the database after a node is updated when you
  488. * can't perform changes in the hook_upate() function of a node not defined by this
  489. * module, or to access values of a node when have not yet been updated.
  490. * An example comes from the tripal_feature module where the URL alias
  491. * of a node cannot be set in the hook_update() function. Therefore
  492. * the tripal_feature module uses this function to reset the url path
  493. * of an updated feature node.
  494. *
  495. * This function is not required. You probably won't need it if you
  496. * don't define a custom node type in the hook_node_info() function. But
  497. * it is node type agnostic, so you can use this function to do any
  498. * activity after insert of a node.
  499. *
  500. */
  501. function tripal_example_node_update($node) {
  502. // add items to other nodes, build index and search results
  503. switch ($node->type) {
  504. case 'chado_example':
  505. // remove any previous alias
  506. //db_query("DELETE FROM {url_alias} WHERE source = :source", array(':source' => "node/$node->nid"));
  507. // set the URL for this example page
  508. //$url_alias = tripal_example_get_example_url($node);
  509. //$path_alias = array("source" => "node/$node->nid", "alias" => $url_alias);
  510. //path_save($path_alias);
  511. break;
  512. }
  513. }
  514. /**
  515. * Implementation of hook_node_view(). This function allows you to
  516. * add custom content to any node page. It is node type agnostic.
  517. * Here we typically use it to add content to our custom node type or
  518. * to other Tripal node types. Typically for Tripal, a content "block"
  519. * (e.g. feature properties, feature dbxref, feature pub) has a corresponding
  520. * template file. Those template files are first defined to Drupal using
  521. * the hook_theme() function defined in the tripal_example.module file. Here
  522. * we can add items to a node's content by calling those templates as needed.
  523. *
  524. * @ingroup tripal_example
  525. */
  526. function tripal_example_node_view($node, $view_mode, $langcode) {
  527. switch ($node->type) {
  528. case 'chado_example':
  529. // there are different ways a node can be viewed. Primarily Tripal
  530. // supports full page view and teaser view.
  531. if ($view_mode == 'full') {
  532. // there is always a base template. This is the template that
  533. // is first shown when the example node type is first displayed
  534. //$node->content['tripal_example_base'] = array(
  535. // '#markup' => theme('tripal_example_base', array('node' => $node)),
  536. // '#tripal_toc_id' => 'base',
  537. // '#tripal_toc_title' => 'Overview',
  538. // '#weight' => -100,
  539. //);
  540. // we can add other templates as well.
  541. //$node->content['tripal_example_properties'] = array(
  542. // '#markup' => theme('tripal_example_properties', array('node' => $node)),
  543. // '#tripal_toc_id' => 'properties',
  544. // '#tripal_toc_title' => 'Properties',
  545. //);
  546. //$node->content['tripal_example_publications'] = array(
  547. // '#markup' => theme('tripal_example_publications', array('node' => $node)),
  548. // '#tripal_toc_id' => 'publications',
  549. // '#tripal_toc_title' => 'Publications',
  550. //);
  551. //$node->content['tripal_example_references'] = array(
  552. // '#markup' => theme('tripal_example_references', array('node' => $node)),
  553. // '#tripal_toc_id' => 'references',
  554. // '#tripal_toc_title' => 'Cross References',
  555. //);
  556. }
  557. // set the content for the teaser view
  558. if ($view_mode == 'teaser') {
  559. //$node->content['tripal_example_teaser'] = array(
  560. // '#value' => theme('tripal_example_teaser', array('node' => $node)),
  561. //);
  562. }
  563. break;
  564. // you can add custom content to any tripal node type by adding
  565. // content to the node in the same way as above.
  566. case 'chado_organism':
  567. break;
  568. case 'chado_library':
  569. break;
  570. case 'chado_stock':
  571. break;
  572. case 'chado_analysis':
  573. break;
  574. // ... etc
  575. }
  576. }