Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Sorry, but this won't happen. Simply hierarchical select is not meant to become a clone of Hierarchical select and duplicate all of its features and stuff.
In the past two months I tried HS and SHS and I would like to thank you all by the effort on SHS. At this moment I have better results with SHS.
The idea to keep it simple is good and probably is helpful to keep SHS with less bugs than SHS (honestly speaking HS is getting better but in my personal opinion SHS has a better support).
So I agree with the idea to keep SHS as simple as possible and not reproduce all the features that we find on HS.
But the labels for level are so necessary to make the user interface more friendly that I would like to vote for this feature.
Hello I think this is a must, for usability reasons!!, the fact that shs is suposed to be "simple", the labels per levl is a feature very necessary and adding the labels will not make shs more "complex" it will keep being "simple"
I wrote a simple script to enable labels for level 2 and onwards.
Hope is useful for someone.
/**
* @file
* Simple script to add labels to shs select boxes
* It creates new label element for each select box at the time the previous level was clicked.
* This script shows three select level, you can add more levels by duplicating the code.
* It assumes that there is already a label for the first select box, as usually provided by views.
* You can position and attribute the new labels using the new divs in a separate css file.
*/
(function ($) {
Drupal.behaviors.propMis = {
attach:function (context, settings) {
$(document.body).on('change','#select-1',function(){
if (!$('#label-2').length > 0) {
$( "#select-2" ).before( '<div id="label-2">My label 2</div>')
}
if ($('#label-3').length > 0) {
$('#label-3').remove();
}
});;
$(document.body).on('change','#select-2',function(){
if (!$('#label-3').length > 0) {
$( "#select-3" ).before('<div id="label-3">My label 3</div>')
}
});
}
};
})(jQuery);
I vote for this as well. As others have pointed out, it just has somewhat bad and confusing usability without it. It's not really a new feature, it's just making it nicely usable.
I used the #6 js file custom_shs_behaviors.zip but when I add that i have encountered an issue that shs does not store the lineage (it stores each new term created using Adding new term from shs as a parent term ) .
So basically lineage is not stored when I add any js code into the shs module
Please let me know if someone has encountered the same issue.
So for me #6 breaks the default functionality of shs and I need to add new terms and store it as a lineage.
Also, When I store a new term using "Add a new term" using shs add new term option the new term gets added but it does not show up the child terms related to that term.
Only when I change the new selected term to none and then back again to new term , I get the child term's dropdown list
otherwise it does not show up.
I am using shs 7.x-1.6
Hash6, Thanks for pointing this out. The SHS module has a bug: If you're creating a new level, then the select of that new level has the same ID as the previous one. I've added two lines to the code and now it should work with the ability of adding new levels as well.
Hello,
jack-pl, I try to implement your file but with no results at all. I place your file in my shs/js folder, change the labels, but nothing happens. Do you have any idea of what am I possibly doing wrong? This feature, to be able to add different label on each taxonomy-level is very useful.
gpantikidis, If nothing happened, that means the file hasn't been implemented to the form. I wrote a simple module, so you can have a quick view how the file works. All you need to do:
Install the Shs Custom Behaviors module - enclosed to this comment
Edit shs_custom_behaviors.module file and replace "YOUR-FORM-ID" with your shs form id
That's it! Now each select of your shs form (defined in hook_form_alter) should have labels ( defined in .js file)
Hi jack-pl , the updated code on #14 works!!! and it stores the parent terms as well so its great work.
I am now facing another isssue which is as follows. I have altered one line for the labels to be displayed in proper position
I have removed the line on shs_custom_behaviors.js (below line 47)
When I use the above line instead of original the "add new terms " functionality breaks somehow and as it does not store parent terms i.e. newly added terms are not stored as child of above terms selected
Hello Hash6, I’m glad I could help. Now you are facing only a theming issue. You can’t use your code because of non-existing label for the first level. You can’t create a label after something that is not exist.
Last Updated: when I first tried it worked but now suddenly it seems to breking again the functionality of add_new_terms in shs
I am again stuck with the same problem mentioned above that parents terms are not stored.
Also one thing I would really like to know(and only if you could spare some time out of your busy schedule nothing urgent) how did my code affect the "add new terms" functionality.
If you could explain me the reason , it would help me in understanding the concept behind it. code (add_new_terms functionality breaks here)
hash6, You're facing only a theming issue. It should be easy to solve, but without html code it would be hard to help. Please use the default bartik theme to see that the code works fine, then find out in your theme what is causing the problem.
A working solution has been committed in #2096423: Accessibility - adding labels to selects. You'll need to override hook_shs_js_settings_alter() or hook_shs_FIELDNAME_js_settings_alter() and set the "labels"-property in the field settings.
See hook_shs_FIELDNAME_js_settings_alter() in shs.api.php for an example.
stBorchert, Are you sure that the hook_shs_FIELDNAME_js_settings_alter() is working?
The file description says:
/**
* @file
*
* This file contains NO WORKING php code; it exists to provide additional
* documentation for doxygen as well as to document hooks in the standard Drupal
* manner.
*/
@jack-pl: Yes, the hooks are working. shs.api.php is a file to document which hooks are available and how to use them. Simply copying the code would not work since you'll have to replace "hook" with the name of your module and "FIELDNAME" with the name of your field (obviously).
I.e. if your module is named "example" and the field is named "field_location", the function would be named "example_shs_field_location_js_settings_alter".
@Force_IAS: trust me, they work fine. You are mixing up labels (HTML: <label/> with option values.
If you enable your custom module, reload the node form and look into the HTML you will see something similar to this:
The labels are hidden by default, you need to display them using custom CSS.
My custom module to show labels for each level is very similar to jack-pl and is also not working. When I turn on Devel and check what field_name on the page per NIKS_Artreaktor instruction I see:
shs_term_node_tid_depth
Is that correct?
If not, what is wrong with function jack-pl posted?
Please advise.
Thanks in advance.
Comments
Comment #1
stBorchertSorry, but this won't happen. Simply hierarchical select is not meant to become a clone of Hierarchical select and duplicate all of its features and stuff.
Comment #2
gilsbert CreditAttribution: gilsbert commentedHi.
In the past two months I tried HS and SHS and I would like to thank you all by the effort on SHS. At this moment I have better results with SHS.
The idea to keep it simple is good and probably is helpful to keep SHS with less bugs than SHS (honestly speaking HS is getting better but in my personal opinion SHS has a better support).
So I agree with the idea to keep SHS as simple as possible and not reproduce all the features that we find on HS.
But the labels for level are so necessary to make the user interface more friendly that I would like to vote for this feature.
Please, think about it.
Regards,
Gilsberty
Comment #3
ssoulless CreditAttribution: ssoulless commentedHello I think this is a must, for usability reasons!!, the fact that shs is suposed to be "simple", the labels per levl is a feature very necessary and adding the labels will not make shs more "complex" it will keep being "simple"
I vote for this feature!
Comment #4
ssoulless CreditAttribution: ssoulless commentedCheck the patch here https://drupal.org/node/2096423
Actually the patch is deprecated, does not work with 7.x-1.x version but it is a good begining for this task.
Comment #5
silurius CreditAttribution: silurius commentedAgree that labeling each level is an important usability requirement. My users are constantly asking me about this.
Comment #6
jack-pl CreditAttribution: jack-pl commentedI have written a custom SHS behavior which solves two issues at once:
The code has been written for SHS view widget with 3 levels forsing to the deepest, but it's very easy to customize for any kind of displaying.
The instruction how to use it - SHS custom behaviours
Comment #7
taitai CreditAttribution: taitai commentedI wrote a simple script to enable labels for level 2 and onwards.
Hope is useful for someone.
Comment #8
matthewv789 CreditAttribution: matthewv789 commentedI vote for this as well. As others have pointed out, it just has somewhat bad and confusing usability without it. It's not really a new feature, it's just making it nicely usable.
Comment #9
casimiro CreditAttribution: casimiro commentedHello Taitai ,
how can I use your script ??
thanks
Comment #10
hash6 CreditAttribution: hash6 commentedI used the #6 js file custom_shs_behaviors.zip but when I add that i have encountered an issue that shs does not store the lineage (it stores each new term created using Adding new term from shs as a parent term ) .
So basically lineage is not stored when I add any js code into the shs module
Please let me know if someone has encountered the same issue.
So for me #6 breaks the default functionality of shs and I need to add new terms and store it as a lineage.
Also, When I store a new term using "Add a new term" using shs add new term option the new term gets added but it does not show up the child terms related to that term.
Only when I change the new selected term to none and then back again to new term , I get the child term's dropdown list
otherwise it does not show up.
I am using shs 7.x-1.6
Comment #11
jack-pl CreditAttribution: jack-pl commentedHash6, Thanks for pointing this out. The SHS module has a bug: If you're creating a new level, then the select of that new level has the same ID as the previous one. I've added two lines to the code and now it should work with the ability of adding new levels as well.
have a look at the new code - SHS custom behaviours
Comment #12
jack-pl CreditAttribution: jack-pl commentedHere's the new file
Comment #13
gpantikidis CreditAttribution: gpantikidis commentedHello,
jack-pl, I try to implement your file but with no results at all. I place your file in my shs/js folder, change the labels, but nothing happens. Do you have any idea of what am I possibly doing wrong? This feature, to be able to add different label on each taxonomy-level is very useful.
Comment #14
jack-pl CreditAttribution: jack-pl commentedgpantikidis, If nothing happened, that means the file hasn't been implemented to the form. I wrote a simple module, so you can have a quick view how the file works. All you need to do:
shs_custom_behaviors.module
file and replace "YOUR-FORM-ID" with your shs form idThat's it! Now each select of your shs form (defined in hook_form_alter) should have labels ( defined in .js file)
Comment #15
hash6 CreditAttribution: hash6 commentedHi jack-pl , the updated code on #14 works!!! and it stores the parent terms as well so its great work.
I am now facing another isssue which is as follows. I have altered one line for the labels to be displayed in proper position
I have removed the line on shs_custom_behaviors.js (below line 47)
https://www.drupal.org/files/issues/old%20working.png
https://www.drupal.org/files/issues/new%20code%20breaking.png
and placed the below line instead of that
$('.shs-select-level-'+level).after("<label for='" + $(this).attr('id') + "' style=' width: " + labelWidth + "px'>" + labels[level] + "</label>");
When I use the above line instead of original the "add new terms " functionality breaks somehow and as it does not store parent terms i.e. newly added terms are not stored as child of above terms selected
Comment #16
jack-pl CreditAttribution: jack-pl commentedHello Hash6, I’m glad I could help. Now you are facing only a theming issue. You can’t use your code because of non-existing label for the first level. You can’t create a label after something that is not exist.
Comment #17
hash6 CreditAttribution: hash6 commentedLast Updated: when I first tried it worked but now suddenly it seems to breking again the functionality of add_new_terms in shs
I am again stuck with the same problem mentioned above that parents terms are not stored.
Also one thing I would really like to know(and only if you could spare some time out of your busy schedule nothing urgent) how did my code affect the "add new terms" functionality.
If you could explain me the reason , it would help me in understanding the concept behind it.
code (add_new_terms functionality breaks here)
code (add_new_terms functionality breaks here as well)
Comment #18
jack-pl CreditAttribution: jack-pl commentedhash6, You're facing only a theming issue. It should be easy to solve, but without html code it would be hard to help. Please use the default bartik theme to see that the code works fine, then find out in your theme what is causing the problem.
Comment #19
stBorchertA working solution has been committed in #2096423: Accessibility - adding labels to selects. You'll need to override
hook_shs_js_settings_alter()
orhook_shs_FIELDNAME_js_settings_alter()
and set the "labels"-property in the field settings.See
hook_shs_FIELDNAME_js_settings_alter()
in shs.api.php for an example.Comment #20
jack-pl CreditAttribution: jack-pl commentedComment #21
stBorchert@jack-pl: Yes, the hooks are working. shs.api.php is a file to document which hooks are available and how to use them. Simply copying the code would not work since you'll have to replace "hook" with the name of your module and "FIELDNAME" with the name of your field (obviously).
I.e. if your module is named "example" and the field is named "field_location", the function would be named "example_shs_field_location_js_settings_alter".
Comment #22
Force_IAS CreditAttribution: Force_IAS commented@stBorchert: the hooks aren't working, I tried with this code
And the labels still " - None - "
Am I doing something wrong or do I need to remove " - None - " label somewhere ?
Comment #23
stBorchert@Force_IAS: trust me, they work fine. You are mixing up labels (HTML:
<label/>
with option values.If you enable your custom module, reload the node form and look into the HTML you will see something similar to this:
The labels are hidden by default, you need to display them using custom CSS.
To change "- None -" to a custom text, you will have to modify the value of the setting any_label (see shs.api.php: hook_shs_js_settings_alter() for an example).
Comment #24
Force_IAS CreditAttribution: Force_IAS commented@stBorchert: Great!
Didn't know about the hidden labels!
Thank you Sir!
Comment #25
jack-pl CreditAttribution: jack-pl commented@stBorchert:
This is exactly what I've done.
My module name is: shs_custom_behaviors
My fieldname is: field_shs_test
Drupal version: 7.34
And my function is:
Unfortunatelly it doesn't work at all. There are no labels, neither visible nor hidden. Any ideas what I'm missing?
Comment #26
NIKS_Artreaktor CreditAttribution: NIKS_Artreaktor commentedjack-pl
install module devel and check what field_name on the page
Comment #27
NIKS_Artreaktor CreditAttribution: NIKS_Artreaktor commentedI have an Bug
If i using api
hook_shs_js_settings_alter()
for field in Views Exposed filter - it working - adding Label
But if you choose child (second select) - ALL -
It reset Main (first select) choice of select to ALL
FIX of this
Add JS code
Comment #28
luckydad CreditAttribution: luckydad commentedThanks for this module.
My custom module to show labels for each level is very similar to jack-pl and is also not working. When I turn on Devel and check what field_name on the page per NIKS_Artreaktor instruction I see:
shs_term_node_tid_depth
Is that correct?
If not, what is wrong with function jack-pl posted?
Please advise.
Thanks in advance.