You are here

README.txt in Hierarchical Select 5.3

Same filename and directory in other branches
  1. 5 README.txt
  2. 5.2 README.txt
  3. 6.3 README.txt
  4. 7.3 README.txt
Description
-----------
This module defines the "hierarchical_select" form element, which is a greatly
enhanced way for letting the user select items in a hierarchy.

Hierarchical Select has the ability to save the entire lineage of a selection
or only the "deepest" selection. You can configure it to force the user to
make a selection as deep as possible in the tree, or allow the user to select
an item anywhere in the tree. Levels can be labeled, you can configure limit
the number of items that can be selected, configure a title for the dropbox,
choose a site-wide animation delay, and so on. You can even create new items
and levels through Hierarchical Select!


Dependencies
------------
* jQuery Update 2.x, NOT 1.x! (http://drupal.org/project/jquery_update)


Integrates with
---------------
* Book (Drupal core)
* Forum (Drupal core)
* Menu (Drupal core)
* Taxonomy (Drupal core)
* Content Taxonomy (http://drupal.org/project/content_taxonomy)
* Taxonomy Subscriptions (http://drupal.org/project/subscriptions)
* Views 5.x-1.x-dev tarball of May 11, 2008 or later (http://drupal.org/project/views)
  or apply this patch: http://drupal.org/files/issues/hs_compatibility.patch


Installation
------------
1) Place this module directory in your "modules" folder (this will usually be
"sites/all/modules/"). Don't install your module in Drupal core's "modules"
folder, since that will cause problems and is bad practice in general. If
"sites/all/modules" doesn't exist yet, just create it.

2) Install the modules it depends on. Don't forget to copy the jquery.js file
included in the jQuery Update module to the "misc" directory!

3) Enable the module.

4) If you want to use it for one or more of your vocabularies, go to
admin/content/taxonomy and click the "edit" link for a vocabulary. Now scroll
down and you'll find a whole range of Hierarchical Select settings. All
settings are explained there as well.


Troubleshooting
---------------
If you ever have problems, make sure to go through these steps:

1) Go to admin/logs/status (i.e. the Status Report). Ensure that the status
   of the following modules is ok:
   - jQuery Update
   - Hierarchical Select
   - Hierarchical Select Taxonomy Views (if installed)
   - Hierarchical Select Content Taxonomy Views (if installed)

2) Ensure that the page isn't being served from your browser's cache. Use
   CTRL+R in Windows/Linux browsers, CMD+R in Mac OS X browsers to enforce the
   browser to reload everything, preventing it from using its cache.

3) When you're getting a JS alert with the following message: "Received an
   invalid response from the server.", ensure that the page (of which this
   form is a part) is *not* being cached.

4) When Hierarchical Select seems to be misbehaving in a certain use case in
   which terms with multiple parents are being used, make sure to enable the
   "Save term lineage" setting.
   Note: you may have to repeat this for every configuration in which the
   vocabulary with terms that have multiple parents are being used. E.g. if
   such a vocabulary is called "A", then go to 
      admin/settings/hierarchical_select/configs
   and edit all configuration that have "A" in the "Hierarchy" column.

In case of problems, don't forget to try a hard refresh in your browser!


Limitations
-----------
- Creating new items in the hierarchy in a multiple parents hierarchy (more
  scientifically: a directed acyclic graph) is *not* supported.
- Not the entire scalability problem can be solved by installing this set of
  modules; read the maximum scalability section for details.
- The child indicators only work in Firefox. This *cannot* be supported in
  Safari or IE. See http://drupal.org/node/180691#comment-1044691.
- The special [save-lineage-termpath] token only works with content_taxonomy
  fields as long as you have the "Save option" set to either "Tag" or "Both".
- In hierarchies where items can have multiple parent items and where you have
  enabled Hierarchical Select's "save lineage" setting, it is impossible to
  remember individual hierarchies, unless the underlying module supports it.
  So far, no module supports this. Hierarchical Select is just a form element,
  not a system for storing hierarchies.
  For example, if you have created a multiple parent vocabulary through the
  Taxonomy module, and you have terms like this:
   A -> C
   A -> D
   B -> C
   B -> D
   If you then save any two lineages in which all four terms exist, all four
   lineages will be rendered by Hierarchical Select, because only the four
   terms are stored and thus there is no way to recover the originally
   selected two lineages.


Maximum scalability
-------------------
While the hs_taxonomy, hs_book, hs_menu and hs_subscriptions modules override
existing form items, those form items are *still* being generated. This can
cause scalability issues.
If you want to fix this, you *will* have to modify the original modules (so
that includes Drupal core modules). Simply move the changes from the
hook_form_alter() implementations into the corresponding form definitions.


Hierarchical Select Taxonomy: using the [save-lineage-termpath] token
---------------------------------------------------------------------
When you're using the Token module, and likely the Pathauto module, and you've
configured your Hierarchical Select to save the lineage, you may want to show
the saved lineage (or the first lineage in case you've also enabled the
dropbox) in your URL. That's possible through the [save-lineage-termpath]
token (and other similar tokens). However, by default it uses the separator
you've configured Pathauto to use (if you aren't using Pathauto then it will
default to a dash). You can override this by setting the hs_taxonomy_separator
variable. Also, when you're using Pathauto and it seems to be stripping the
separator you've configured, then you may want to configure that character in
Pathauto's Punctuation settings to "No action (do not replace)".


Using the dropbox in Views exposed filters
------------------------------------------
This can be very tricky, due to a combination of the respective limitations of
Taxonomy and Views exposed filters.
See http://drupal.org/node/346033.


Rendering hierarchy lineages when viewing content
-------------------------------------------------
Hierarchical Select is obviously only used for input. Hence it is only used on
the create/edit forms of content.
Combine that with the fact that Hierarchical Select is the only module capable
of restoring the lineage of saved items (e.g. Taxonomy terms). None of the
Drupal core modules is capable of storing the lineage, but Hierarchical Select
can reconstruct it relatively efficiently. However, this lineage is only
visible when creating/editing content, not when viewing it.
To allow you to display the lineages of stored items, I have provided a
theming function that you can call from within e.g. your node.tpl.php file:
the theme_hierarchical_select_selection_as_lineages($selection, $config)
function.

Sample usage (using Taxonomy and Hierarchical Select Taxonomy):
  <?php if ($taxonomy):
    require_once(drupal_get_path('module', 'hierarchical_select') . '/includes/common.inc');
    $vid = 2;                                                    // Vocabulary ID. CHANGE THIS!
    $config_id = "taxonomy-$vid";                                // Generate the config ID.
    $config = hierarchical_select_common_config_get($config_id); // Get the Hierarchical Select configuration through the config ID.
    $config['module'] = 'hs_taxonomy';                           // Set the module.
    $config['params']['vid'] = $vid;                             // Set the parameters.
  ?>
    <div class="terms"><?php print theme('hierarchical_select_selection_as_lineages', $node->taxonomy, $config); ?></div>
  <?php endif; ?>

This will automatically render all lineages for vocabulary 2 (meaning that if
you want to render the lineages of multiple vocabularies, you'll have to clone
this piece of code once for every vocabulary). It will also automatically get
the current Hierarchical Select configuration for that vocabulary.

Alternatively, you could provide the $config array yourself. Only three keys
are required: 1) module, 2) params, 3) save_lineage. For example:
  <?php if ($taxonomy):
    $vid = 2;                          // Vocabulary ID. CHANGE THIS!
    $config['module'] = 'hs_taxonomy'; // Set the module.
    $config['params']['vid'] = $vid;   // Set the parameters.
    $config['save_lineage'] = 1;       // save_lineage setting is enabled. CHANGE THIS!
  ?>
    <div class="terms"><?php print theme('hierarchical_select_selection_as_lineages', $node->taxonomy, $config); ?></div>
  <?php endif; ?>

If you don't like how the lineage is displayed, simply override the
theme_hierarchical_select_selection_as_lineages() function from within your
theme, create e.g. garland_hierarchical_select_selection_as_lineages().


Addressing Views exposed filters display issues
-----------------------------------------------
When using Hierarchical Select to alter an exposed Views filter (i.e. an 
exposed taxonomy filter), you may run into display issues due to the Views
method theme_views_filters(), which renders filters as columns within a table.
This results in behavior where the select boxes within the Hierarchical Select
widget may split onto multiple lines or be too cramped together. The following
theme override sample, written for the Zen theme, renders the filters as rows 
within a table, leaving much more room for the Hierarchical Select widget. To
use, follow the instructions for overriding theme functions described at 
http://drupal.org/node/55126.

<?php
function zen_views_filters($form) {
  $view = $form['view']['#value'];
  $rows = array();
  $form['submit']['#value'] = t('Search');
  if (isset($view->exposed_filter)) {
    foreach ($view->exposed_filter as $count => $expose) {
      $rows[] = array(
        array('data' => $expose['label'], 'header' => TRUE),
        drupal_render($form["op$count"]) . drupal_render($form["filter$count"]),
      );
    }
  }
  $rows[] = array(
    array('data' => '', 'header' => TRUE),
    drupal_render($form['submit'])
  );
  if (count($rows) > 1) {
    $output = drupal_render($form['q']) . theme('table', array(), $rows) . drupal_render($form);
  }
  else {
    $output = drupal_render($form);
  }
  return $output;
}
?>


Setting a fixed size
--------------------
When you don't want users to be able to resize a hierarchical select
themselves, you can set a fixed size in advance yourself
Setting #size to >1 does *not* generate #multiple = TRUE selects! And the
opposite is also true. #multiple sets the "multiple" HTML attribute. This
enables the user to select multiple options of a select. #size just controls
the "size" HTML attribute. This increases the vertical size of selects,
thereby showing more options.
See http://www.w3.org/TR/html401/interact/forms.html#adef-size-SELECT.


Sponsors
--------
* Initial development:
   Paul Ektov of http://autobin.ru.
* Abstraction, to let other modules than taxonomy hook in:
   Etienne Leers of http://creditcalc.biz.
* Support for saving the term lineage:
   Paul Ektov of http://autobin.ru.
* Multiple select support:
   Marmaladesoul, http://marmaladesoul.com.
* Taxonomy Subscriptions support:
   Mr Bidster Inc.
* Ability to create new items/levels:
   The Worx Company, http://www.worxco.com.
* Ability to only show items that are associated with at least one entity:
   Merge, http://merge.nl.


Author
------
Wim Leers

* mail: work@wimleers.com
* website: http://wimleers.com/work

The author can be contacted for paid customizations of this module as well as
Drupal consulting and development.

File

README.txt
View source
  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. Dependencies
  13. ------------
  14. * jQuery Update 2.x, NOT 1.x! (http://drupal.org/project/jquery_update)
  15. Integrates with
  16. ---------------
  17. * Book (Drupal core)
  18. * Forum (Drupal core)
  19. * Menu (Drupal core)
  20. * Taxonomy (Drupal core)
  21. * Content Taxonomy (http://drupal.org/project/content_taxonomy)
  22. * Taxonomy Subscriptions (http://drupal.org/project/subscriptions)
  23. * Views 5.x-1.x-dev tarball of May 11, 2008 or later (http://drupal.org/project/views)
  24. or apply this patch: http://drupal.org/files/issues/hs_compatibility.patch
  25. Installation
  26. ------------
  27. 1) Place this module directory in your "modules" folder (this will usually be
  28. "sites/all/modules/"). Don't install your module in Drupal core's "modules"
  29. folder, since that will cause problems and is bad practice in general. If
  30. "sites/all/modules" doesn't exist yet, just create it.
  31. 2) Install the modules it depends on. Don't forget to copy the jquery.js file
  32. included in the jQuery Update module to the "misc" directory!
  33. 3) Enable the module.
  34. 4) If you want to use it for one or more of your vocabularies, go to
  35. admin/content/taxonomy and click the "edit" link for a vocabulary. Now scroll
  36. down and you'll find a whole range of Hierarchical Select settings. All
  37. settings are explained there as well.
  38. Troubleshooting
  39. ---------------
  40. If you ever have problems, make sure to go through these steps:
  41. 1) Go to admin/logs/status (i.e. the Status Report). Ensure that the status
  42. of the following modules is ok:
  43. - jQuery Update
  44. - Hierarchical Select
  45. - Hierarchical Select Taxonomy Views (if installed)
  46. - Hierarchical Select Content Taxonomy Views (if installed)
  47. 2) Ensure that the page isn't being served from your browser's cache. Use
  48. CTRL+R in Windows/Linux browsers, CMD+R in Mac OS X browsers to enforce the
  49. browser to reload everything, preventing it from using its cache.
  50. 3) When you're getting a JS alert with the following message: "Received an
  51. invalid response from the server.", ensure that the page (of which this
  52. form is a part) is *not* being cached.
  53. 4) When Hierarchical Select seems to be misbehaving in a certain use case in
  54. which terms with multiple parents are being used, make sure to enable the
  55. "Save term lineage" setting.
  56. Note: you may have to repeat this for every configuration in which the
  57. vocabulary with terms that have multiple parents are being used. E.g. if
  58. such a vocabulary is called "A", then go to
  59. admin/settings/hierarchical_select/configs
  60. and edit all configuration that have "A" in the "Hierarchy" column.
  61. In case of problems, don't forget to try a hard refresh in your browser!
  62. Limitations
  63. -----------
  64. - Creating new items in the hierarchy in a multiple parents hierarchy (more
  65. scientifically: a directed acyclic graph) is *not* supported.
  66. - Not the entire scalability problem can be solved by installing this set of
  67. modules; read the maximum scalability section for details.
  68. - The child indicators only work in Firefox. This *cannot* be supported in
  69. Safari or IE. See http://drupal.org/node/180691#comment-1044691.
  70. - The special [save-lineage-termpath] token only works with content_taxonomy
  71. fields as long as you have the "Save option" set to either "Tag" or "Both".
  72. - In hierarchies where items can have multiple parent items and where you have
  73. enabled Hierarchical Select's "save lineage" setting, it is impossible to
  74. remember individual hierarchies, unless the underlying module supports it.
  75. So far, no module supports this. Hierarchical Select is just a form element,
  76. not a system for storing hierarchies.
  77. For example, if you have created a multiple parent vocabulary through the
  78. Taxonomy module, and you have terms like this:
  79. A -> C
  80. A -> D
  81. B -> C
  82. B -> D
  83. If you then save any two lineages in which all four terms exist, all four
  84. lineages will be rendered by Hierarchical Select, because only the four
  85. terms are stored and thus there is no way to recover the originally
  86. selected two lineages.
  87. Maximum scalability
  88. -------------------
  89. While the hs_taxonomy, hs_book, hs_menu and hs_subscriptions modules override
  90. existing form items, those form items are *still* being generated. This can
  91. cause scalability issues.
  92. If you want to fix this, you *will* have to modify the original modules (so
  93. that includes Drupal core modules). Simply move the changes from the
  94. hook_form_alter() implementations into the corresponding form definitions.
  95. Hierarchical Select Taxonomy: using the [save-lineage-termpath] token
  96. ---------------------------------------------------------------------
  97. When you're using the Token module, and likely the Pathauto module, and you've
  98. configured your Hierarchical Select to save the lineage, you may want to show
  99. the saved lineage (or the first lineage in case you've also enabled the
  100. dropbox) in your URL. That's possible through the [save-lineage-termpath]
  101. token (and other similar tokens). However, by default it uses the separator
  102. you've configured Pathauto to use (if you aren't using Pathauto then it will
  103. default to a dash). You can override this by setting the hs_taxonomy_separator
  104. variable. Also, when you're using Pathauto and it seems to be stripping the
  105. separator you've configured, then you may want to configure that character in
  106. Pathauto's Punctuation settings to "No action (do not replace)".
  107. Using the dropbox in Views exposed filters
  108. ------------------------------------------
  109. This can be very tricky, due to a combination of the respective limitations of
  110. Taxonomy and Views exposed filters.
  111. See http://drupal.org/node/346033.
  112. Rendering hierarchy lineages when viewing content
  113. -------------------------------------------------
  114. Hierarchical Select is obviously only used for input. Hence it is only used on
  115. the create/edit forms of content.
  116. Combine that with the fact that Hierarchical Select is the only module capable
  117. of restoring the lineage of saved items (e.g. Taxonomy terms). None of the
  118. Drupal core modules is capable of storing the lineage, but Hierarchical Select
  119. can reconstruct it relatively efficiently. However, this lineage is only
  120. visible when creating/editing content, not when viewing it.
  121. To allow you to display the lineages of stored items, I have provided a
  122. theming function that you can call from within e.g. your node.tpl.php file:
  123. the theme_hierarchical_select_selection_as_lineages($selection, $config)
  124. function.
  125. Sample usage (using Taxonomy and Hierarchical Select Taxonomy):
  126. require_once(drupal_get_path('module', 'hierarchical_select') . '/includes/common.inc');
  127. $vid = 2; // Vocabulary ID. CHANGE THIS!
  128. $config_id = "taxonomy-$vid"; // Generate the config ID.
  129. $config = hierarchical_select_common_config_get($config_id); // Get the Hierarchical Select configuration through the config ID.
  130. $config['module'] = 'hs_taxonomy'; // Set the module.
  131. $config['params']['vid'] = $vid; // Set the parameters.
  132. ?>
  133. taxonomy, $config); ?>
  134. This will automatically render all lineages for vocabulary 2 (meaning that if
  135. you want to render the lineages of multiple vocabularies, you'll have to clone
  136. this piece of code once for every vocabulary). It will also automatically get
  137. the current Hierarchical Select configuration for that vocabulary.
  138. Alternatively, you could provide the $config array yourself. Only three keys
  139. are required: 1) module, 2) params, 3) save_lineage. For example:
  140. $vid = 2; // Vocabulary ID. CHANGE THIS!
  141. $config['module'] = 'hs_taxonomy'; // Set the module.
  142. $config['params']['vid'] = $vid; // Set the parameters.
  143. $config['save_lineage'] = 1; // save_lineage setting is enabled. CHANGE THIS!
  144. ?>
  145. taxonomy, $config); ?>
  146. If you don't like how the lineage is displayed, simply override the
  147. theme_hierarchical_select_selection_as_lineages() function from within your
  148. theme, create e.g. garland_hierarchical_select_selection_as_lineages().
  149. Addressing Views exposed filters display issues
  150. -----------------------------------------------
  151. When using Hierarchical Select to alter an exposed Views filter (i.e. an
  152. exposed taxonomy filter), you may run into display issues due to the Views
  153. method theme_views_filters(), which renders filters as columns within a table.
  154. This results in behavior where the select boxes within the Hierarchical Select
  155. widget may split onto multiple lines or be too cramped together. The following
  156. theme override sample, written for the Zen theme, renders the filters as rows
  157. within a table, leaving much more room for the Hierarchical Select widget. To
  158. use, follow the instructions for overriding theme functions described at
  159. http://drupal.org/node/55126.
  160. function zen_views_filters($form) {
  161. $view = $form['view']['#value'];
  162. $rows = array();
  163. $form['submit']['#value'] = t('Search');
  164. if (isset($view->exposed_filter)) {
  165. foreach ($view->exposed_filter as $count => $expose) {
  166. $rows[] = array(
  167. array('data' => $expose['label'], 'header' => TRUE),
  168. drupal_render($form["op$count"]) . drupal_render($form["filter$count"]),
  169. );
  170. }
  171. }
  172. $rows[] = array(
  173. array('data' => '', 'header' => TRUE),
  174. drupal_render($form['submit'])
  175. );
  176. if (count($rows) > 1) {
  177. $output = drupal_render($form['q']) . theme('table', array(), $rows) . drupal_render($form);
  178. }
  179. else {
  180. $output = drupal_render($form);
  181. }
  182. return $output;
  183. }
  184. ?>
  185. Setting a fixed size
  186. --------------------
  187. When you don't want users to be able to resize a hierarchical select
  188. themselves, you can set a fixed size in advance yourself
  189. Setting #size to >1 does *not* generate #multiple = TRUE selects! And the
  190. opposite is also true. #multiple sets the "multiple" HTML attribute. This
  191. enables the user to select multiple options of a select. #size just controls
  192. the "size" HTML attribute. This increases the vertical size of selects,
  193. thereby showing more options.
  194. See http://www.w3.org/TR/html401/interact/forms.html#adef-size-SELECT.
  195. Sponsors
  196. --------
  197. * Initial development:
  198. Paul Ektov of http://autobin.ru.
  199. * Abstraction, to let other modules than taxonomy hook in:
  200. Etienne Leers of http://creditcalc.biz.
  201. * Support for saving the term lineage:
  202. Paul Ektov of http://autobin.ru.
  203. * Multiple select support:
  204. Marmaladesoul, http://marmaladesoul.com.
  205. * Taxonomy Subscriptions support:
  206. Mr Bidster Inc.
  207. * Ability to create new items/levels:
  208. The Worx Company, http://www.worxco.com.
  209. * Ability to only show items that are associated with at least one entity:
  210. Merge, http://merge.nl.
  211. Author
  212. ------
  213. Wim Leers
  214. * mail: work@wimleers.com
  215. * website: http://wimleers.com/work
  216. The author can be contacted for paid customizations of this module as well as
  217. Drupal consulting and development.