README.txt 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. Description
  2. -----------
  3. This module defines the "hierarchical_select" form element, which is a greatly
  4. enhanced way for letting the user select items in a hierarchy.
  5. Hierarchical Select has the ability to save the entire lineage of a selection
  6. or only the "deepest" selection. You can configure it to force the user to
  7. make a selection as deep as possible in the tree, or allow the user to select
  8. an item anywhere in the tree. Levels can be labeled, you can configure limit
  9. the number of items that can be selected, configure a title for the dropbox,
  10. choose a site-wide animation delay, and so on. You can even create new items
  11. and levels through Hierarchical Select!
  12. Integrates with
  13. ---------------
  14. * Taxonomy (Drupal core)
  15. Installation
  16. ------------
  17. 1) Place this module directory in your "modules" folder (this will usually be
  18. "sites/all/modules/"). Don't install your module in Drupal core's "modules"
  19. folder, since that will cause problems and is bad practice in general. If
  20. "sites/all/modules" doesn't exist yet, just create it.
  21. 2) Enable the Hierarchical Select and Hierarchical Select Taxonomy modules.
  22. 3) If you want to use it for one or more of your vocabularies, go to
  23. admin/structure/types and click the "manage fields" link for a content type on
  24. which you're using a Term reference field. Click the "edit" link for this Term
  25. reference field and then go to the "widget type" tab in the upper right corner.
  26. There, you can choose the "Hierarchical Select" widget type, and when you do,
  27. the entire Hierarchical Select configuration UI will appear: here you'll find
  28. a whole range of Hierarchical Select settings. All settings are explained
  29. there as well!
  30. Troubleshooting
  31. ---------------
  32. If you ever have problems, make sure to go through these steps:
  33. 1) Go to admin/reports/status (i.e. the Status Report). Ensure that the status
  34. of the Hierarchical Select module is ok.
  35. 2) Ensure that the page isn't being served from your browser's cache. Use
  36. CTRL+R in Windows/Linux browsers, CMD+R in Mac OS X browsers to enforce the
  37. browser to reload everything, preventing it from using its cache.
  38. 3) When you're getting a JS alert with the following message: "Received an
  39. invalid response from the server.", ensure that the page (of which this
  40. form is a part) is *not* being cached.
  41. 4) When Hierarchical Select seems to be misbehaving in a certain use case in
  42. which terms with multiple parents are being used, make sure to enable the
  43. "Save term lineage" setting.
  44. Note: you may have to repeat this for every configuration in which the
  45. vocabulary with terms that have multiple parents are being used. E.g. if
  46. such a vocabulary is called "A", then go to
  47. admin/config/content/hierarchical_select/configs
  48. and edit all configuration that have "A" in the "Hierarchy" column.
  49. In case of problems, don't forget to try a hard refresh in your browser!
  50. Limitations
  51. -----------
  52. - Creating new items in the hierarchy in a multiple parents hierarchy (more
  53. scientifically: a directed acyclic graph) is *not* supported.
  54. - Not the entire scalability problem can be solved by installing this set of
  55. modules; read the maximum scalability section for details.
  56. - The child indicators only work in Firefox. This *cannot* be supported in
  57. Safari or IE. See http://drupal.org/node/180691#comment-1044691.
  58. - The special [save-lineage-termpath] token only works with content_taxonomy
  59. fields as long as you have the "Save option" set to either "Tag" or "Both".
  60. - In hierarchies where items can have multiple parent items and where you have
  61. enabled Hierarchical Select's "save lineage" setting, it is impossible to
  62. remember individual hierarchies, unless the underlying module supports it.
  63. So far, no module supports this. Hierarchical Select is just a form element,
  64. not a system for storing hierarchies.
  65. For example, if you have created a multiple parent vocabulary through the
  66. Taxonomy module, and you have terms like this:
  67. A -> C
  68. A -> D
  69. B -> C
  70. B -> D
  71. If you then save any two lineages in which all four terms exist, all four
  72. lineages will be rendered by Hierarchical Select, because only the four
  73. terms are stored and thus there is no way to recover the originally selected
  74. two lineages.
  75. - You can NOT expect the Hierarchical Select Taxonomy module to automagically
  76. fix all existing nodes when you enable or disable the "save lineage" setting
  77. and neither can you expect it to keep working properly when you reorganize
  78. the term hierarchy. There's nothing I can do about this. Hierarchical Select
  79. is merely a form element, it can't be held responsible for features that
  80. Drupal core lacks or supports poorly.
  81. See the following issues:
  82. * http://drupal.org/node/1023762#comment-4054386
  83. * http://drupal.org/node/976394#comment-4054456
  84. Rendering hierarchy lineages when viewing content
  85. -------------------------------------------------
  86. Hierarchical Select is obviously only used for input. Hence it is only used on
  87. the create/edit forms of content.
  88. Combine that with the fact that Hierarchical Select is the only module capable
  89. of restoring the lineage of saved items (e.g. Taxonomy terms). None of the
  90. Drupal core modules is capable of storing the lineage, but Hierarchical Select
  91. can reconstruct it relatively efficiently. However, this lineage is only
  92. visible when creating/editing content, not when viewing it.
  93. To allow you to display the lineages of stored items, I have provided a
  94. theming function that you can call from within e.g. your node.tpl.php file:
  95. the theme_hierarchical_select_selection_as_lineages($selection, $config)
  96. function.
  97. Sample usage (using Taxonomy and Hierarchical Select Taxonomy):
  98. <?php if ($taxonomy):
  99. require_once(drupal_get_path('module', 'hierarchical_select') . '/includes/common.inc');
  100. $vid = 2; // Vocabulary ID. CHANGE THIS!
  101. $config_id = "taxonomy-$vid"; // Generate the config ID.
  102. $config = hierarchical_select_common_config_get($config_id); // Get the Hierarchical Select configuration through the config ID.
  103. $config['module'] = 'hs_taxonomy'; // Set the module.
  104. $config['params']['vid'] = $vid; // Set the parameters.
  105. ?>
  106. <div class="terms"><?php print theme('hierarchical_select_selection_as_lineages', $node->taxonomy, $config); ?></div>
  107. <?php endif; ?>
  108. This will automatically render all lineages for vocabulary 2 (meaning that if
  109. you want to render the lineages of multiple vocabularies, you'll have to clone
  110. this piece of code once for every vocabulary). It will also automatically get
  111. the current Hierarchical Select configuration for that vocabulary.
  112. Alternatively, you could provide the $config array yourself. Only three keys
  113. are required: 1) module, 2) params, 3) save_lineage. For example:
  114. <?php if ($taxonomy):
  115. $vid = 2; // Vocabulary ID. CHANGE THIS!
  116. $config['module'] = 'hs_taxonomy'; // Set the module.
  117. $config['params']['vid'] = $vid; // Set the parameters.
  118. $config['save_lineage'] = 1; // save_lineage setting is enabled. CHANGE THIS!
  119. ?>
  120. <div class="terms"><?php print theme('hierarchical_select_selection_as_lineages', $node->taxonomy, $config); ?></div>
  121. <?php endif; ?>
  122. If you don't like how the lineage is displayed, simply override the
  123. theme_hierarchical_select_selection_as_lineages() function from within your
  124. theme, create e.g. garland_hierarchical_select_selection_as_lineages().
  125. It's also worth mentioning that the 'hs_taxonomy_tree' tag was added to the
  126. queries that build the term tree. As a result now you can easily change/filter
  127. the elements that are selected by the module (see hs_taxonomy.module for more
  128. info).
  129. Setting a fixed size
  130. --------------------
  131. When you don't want users to be able to resize a hierarchical select
  132. themselves, you can set a fixed size in advance yourself
  133. Setting #size to >1 does *not* generate #multiple = TRUE selects! And the
  134. opposite is also true. #multiple sets the "multiple" HTML attribute. This
  135. enables the user to select multiple options of a select. #size just controls
  136. the "size" HTML attribute. This increases the vertical size of selects,
  137. thereby showing more options.
  138. See http://www.w3.org/TR/html401/interact/forms.html#adef-size-SELECT.
  139. Sponsors
  140. --------
  141. * Initial development:
  142. Paul Ektov of http://autobin.ru.
  143. * Abstraction, to let other modules than taxonomy hook in:
  144. Etienne Leers of http://creditcalc.biz.
  145. * Support for saving the term lineage:
  146. Paul Ektov of http://autobin.ru.
  147. * Multiple select support:
  148. Marmaladesoul, http://marmaladesoul.com.
  149. * Taxonomy Subscriptions support:
  150. Mr Bidster Inc.
  151. * Ability to create new items/levels:
  152. The Worx Company, http://www.worxco.com.
  153. * Ability to only show items that are associated with at least one entity:
  154. Merge, http://merge.nl.
  155. * Views 2 support:
  156. Merge, http://merge.nl.
  157. * Initial Drupal 7 port + folow-up fixes:
  158. PingV, http://pingv.com.
  159. * Port of "save lineage" functionality to Drupal 7:
  160. Bancard Data Service
  161. Author
  162. ------
  163. Wim Leers
  164. * website: http://wimleers.com/
  165. * contact: http://wimleers.com/contact
  166. The author can be contacted for paid development on this module. This can vary
  167. from new features to Hierarchical Select itself, to new implementations (i.e.
  168. support for new kinds of hierarchies).