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.
I have exposed filter with 0 depth.
Users can pick parent term for displaying results which is fine, but on child it says "none" so it looks like they have to choose child too. Changing word "none" to "any" would be much better but i do not know where to change this.
Comment | File | Size | Author |
---|---|---|---|
#30 | 3.PNG | 34.03 KB | LaPi |
#30 | 2.PNG | 23.02 KB | LaPi |
#30 | 1.PNG | 38.8 KB | LaPi |
#28 | scrnn.png | 103.34 KB | Victoriaxvx |
#26 | Screen Shot 2016-02-17 at 10.37.32.png | 97.48 KB | Victoriaxvx |
Comments
Comment #1
svouthi CreditAttribution: svouthi commentedHello,
This text is easily changed in the shs.js file found in the module's js folder.
Simply change "None" in the line:
"options[options.length] = new Option(Drupal.t('- None -'), 0);"
to whatever you would like. (I used "Please Select")
Comment #2
Sinan Erdem CreditAttribution: Sinan Erdem commentedChanging a text from the module files is not a good idea. Upgrading the module will remove this modification.
I think there should be an option to change this text. -any- or -all- is more logical words because even the user doesnt select this, all results will be shown.
Comment #3
svouthi CreditAttribution: svouthi commentedSince each use case is different, the preferred start content of the field will vary, so there will always be someone with the need to alter it. I am suggesting this simple modification until there is a more user-friendly way to designate the text. In my use case, the filter is required, so "Any" doesn't make sense since no content is shown until a selection is made.
Comment #4
svouthi CreditAttribution: svouthi commentedIn the dev version, the text to change is found in shs_handler_filter_term_node_tid.inc in the line:
'any_label' => variable_get('views_exposed_filter_any_label', 'new_any') == 'old_any' ? t('<Any>') : t('- Any -'),
Change the "Any" text to whatever best suits your application.
Comment #5
stBorchertTry the latest development version. It uses the default labels from views so there is "- Any -" now instead of "- None -" in exposed filters.
Comment #6
igorski CreditAttribution: igorski commentedI needed a label saying “please select”. After elaborating for a couple of days, I came up with this solution:
Not very elegant, but efficient.
Comment #7
Angry Dan CreditAttribution: Angry Dan commentedSee the attached patch which should provide this option.
Comment #8
weldUAE CreditAttribution: weldUAE commentedI needed to change none to any and the development version does this very well and it will get all the results from the view. However, once I make a selection in the first level the second level will show with "any" but the result will be always 0 until I select the deepest level, in my case 4 levels.
Comment #9
weldUAE CreditAttribution: weldUAE commentedAny updates?
Comment #10
Yuri CreditAttribution: Yuri commentedIf I select 'Any' then no results are given. This should be all results.
Comment #11
Yuri CreditAttribution: Yuri commentedComment #12
davidneedhamI have the same problem as @weldUAE.
It's great that it says "any", however choosing a parent term will not show all nodes that selected child terms of the parent term. Bummer. Any ideas?
Comment #13
weldUAE CreditAttribution: weldUAE commentedI don't remember where I found the solution but this is what you need to do to be able to show child terms in the result.
First you will need to update to the latest dev of shs. Then in views you need to select "Content: Has taxonomy terms (with depth; Simple hierarchical select)". In settings you will need to select vocabulary and set the depth. It is important to set the depth; If you have one level of child terms then set the depth to 1
Comment #14
inno81 CreditAttribution: inno81 commentedI have the same problem as #10, and possibly #12:
If I select 'Any' then no results are given. This should be all results.
Comment #15
akalata CreditAttribution: akalata commented#13 works great, update to -dev and adjust the new settings. Thanks @weldUAE!
Comment #16
Kurt.j CreditAttribution: Kurt.j commented#13 worked for me as well. Thanks.
Comment #17
davidneedham#13 works for me as well. I didn't apply any patches, I just had to build the exposed filter in a different way.
This issue should probably be restructured to suggest better documentation (or possibly removing the option that we all ended up using the first time around).
Comment #20
stBorchertI've added the new hooks
hook_shs_js_settings_alter()
andhook_shs_FIELDNAME_js_settings_alter()
(see shs.api.php for more details), so its now very easy to override "- None -" on a per-field level using a custom module.Comment #22
ashopin CreditAttribution: ashopin commented#13 worked for me!
Comment #24
Victoriaxvx CreditAttribution: Victoriaxvx as a volunteer and commented#20 #20 Sorry but i can't understand how to use this hook.
I created a custom module with the code but nothing has changed
I'll very thankful for any help.
Comment #25
stBorchert@Victoriaxvx: you need to replace "hook" with the name of your module in the function name to make it work.
Additionally, you've renamed the second parameter of the function to
$field_provence
which will not work, since you use$field
within the function.So if your module is named "mymodule" the hook implementation will look like this:
hth,
Stefan
Comment #26
Victoriaxvx CreditAttribution: Victoriaxvx as a volunteer and commented#25 Oh thank you so much!
now i have a little confuse with a name of field, is this name that have a content type, or name of exposed filter?
i tried with this examples, but it not work for me:
I really don't understand what is name i need to use.
This is the field on admin content type page:
And this is the exposed filter:
Sorry for stupid questions. but is really a little information on google
Comment #27
stBorchertYou may simply use
hook_shs_js_settings_alter()
(see shs.api.php for further reference) and print the field name. This is the easiest way to get the correct name.Comment #28
Victoriaxvx CreditAttribution: Victoriaxvx as a volunteer and commented#27 hook_shs_js_settings_alter() isn't woork too.
i used that example:
function custom_shs_js_settings_alter(&$settings_js, $field_name, $vocabulary_identifier) {
if ($field_name == 'field_provence') {
foreach ($settings_js['shs'] as $field => $container) {
foreach ($container as $identifier => $settings) {
$settings_js['shs'][$field][$identifier]['any_label'] = t(' - Select an item - ');
}
}
}
}
But any time i have -none- label and can't change it.
I tried various combinations of field name like field_provence, field_provence_und_0_tid, field_provence_und_0_tid_select_1, but it never work for me, i haven't any idea how to change -none- for country and city.
Comment #29
m.attar CreditAttribution: m.attar commentedHi, You can use this solution using Javascript:
Comment #30
LaPi CreditAttribution: LaPi commentedHi everyone, I've got the same issue. When I select "any" in a child terms list there is no resoults. I can't fix with #13 because my filter comes from a field collection.
I have a content type with a field collection. One of the field in the field collection is a term reference.
I created a view with a relationship with the field collection and I create an exposed filter for term reference in the field collection (1.png) and I choose shs (2.png). I set filter as exposed (3.png). All work fine, but If choose any in a child list terms it display nothing and I can't set depth as #13 said.
Any ideas?
Comment #31
c@sper CreditAttribution: c@sper commentedHi, I have the same problem as #10 and #14: selecting -any- gives no result ... but the solution given by #13 don't work form me, the problem persist.
I have drupal 7.59 and SHS 7.x-1.7 ... any suggestions?
[solved] I selected "allow multiple choice" in shs select ... selecting "single choice" it works