README.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. This module is provided as a template for creating a custom Tripal Extension
  2. Module for Drupal 7 and Tripal 2.x.
  3. Drupal does provide quite a bit of documentation on its website at
  4. http://www.drupal.org but the easiest way to learn to program a Drupal module
  5. is to purchase the following book:
  6. Tomlinson, VanDyk. Pro Drupal Development. 2010. ISBN-13: 978-1430228387
  7. But this quick link can help get you started:
  8. https://drupal.org/developing/modules/7
  9. Briefly, to create a Drupal module you must
  10. 1) Create a directory to house all of your module's files
  11. 2) Create a .info inside of the directory which provides information about your
  12. module to Drupal
  13. 3) Create a .module file which contains the functions used by your module
  14. 4) Create a .install file which contains the functions used for installation,
  15. enabling, disabling and uninstallation of your module.
  16. Examine the example functions and documentation in each of the files in this
  17. example module to learn how Tripal uses the Drupal API.
  18. -------------------------
  19. DIRECTORY AND FILE NAMING
  20. -------------------------
  21. When creating your Tripal Extension module, the following directory structure
  22. and file naming is suggested:
  23. For the required files:
  24. [module dir]/[module name].info
  25. [module dir]/[module name].module
  26. [module dir]/[module name].install
  27. If you want to include Drush commands for your module
  28. [module dir]/[module name].drush.inc
  29. If you want to integrate with Drupal Views 3.x:
  30. [module dir]/[module name].views.inc
  31. [module dir]/[module name].views_default.inc
  32. Include Files
  33. -------------
  34. To limit the size of files, some functionality can be placed inside of
  35. "include" files. Include files are placed inside of an 'includes' directory.
  36. [module dir]/includes
  37. If your module creates a node type that uses data housed in Chado, you should
  38. place all of the Drupal hooks for nodes inside of an include named:
  39. [module dir]/includes/[module name].chado_node.inc
  40. If your module has an administrative interface, all of the functions related to
  41. administration should go in an include file named:
  42. [module dir]/includes/[module name].admin.inc
  43. All other include files should be named in the following way:
  44. [module dir]/includes/[module name].[function].inc
  45. where [function] is a brief description of the functionality provided by the
  46. include file. Please only use underscores inside of the [function] (no dashes
  47. or periods).
  48. Theme Files
  49. -------------
  50. Tripal primarily uses template files for displaying content from Chado. This
  51. allows anyone to easily change the way data is displayed without needing to
  52. delve into the module's source code. A template typically provides data for
  53. a single data type (e.g. feature) or association (e.g. properties associated to
  54. features, or publications associated with featurmaps, etc.). These template
  55. files and any JavaScript, CSS or images needed to support them are all
  56. housed inside of a 'theme' directory with the following structure:
  57. [module dir]/theme
  58. [module dir]/theme/css (for CSS files)
  59. [module dir]/theme/js (for JS files)
  60. [module dir]/theme/images (for images)
  61. [module dir]/theme/templates (for all Drupal template files)
  62. All Drupal hooks and functions related to theming of content should go in the
  63. file named:
  64. [module dir]/theme/[module name].theme.inc
  65. The functions in that file will typically be functions which directly
  66. generate content for a page or "preprocess" hooks that prepare variables that
  67. are passed to templates.
  68. Template files are named in the following way
  69. [module dir]/theme/templates/[module name]_[function].tpl.php.
  70. Notice that templates have an underscore separating the [module name] from the
  71. [function]. Typically a period is used (as with include files) but for
  72. backwards compatibility the underscores are kept.
  73. API Files
  74. ---------
  75. If your module will provide a set of functions that can be used as an
  76. Application Programming Interface (API), then those functions should be placed
  77. in files housed in the 'api' directory:
  78. [module dir]/api
  79. When creating API functions try to organize them into groups of related function
  80. and separate them into files by function with the following naming:
  81. [module dir]/api/[module name].[function].api.inc