Does not show terms in hierarchy

Created on 30 April 2020, almost 5 years ago
Updated 17 February 2023, about 2 years ago

I have a view with a filter "Has taxonomy terms (with depth)" and "Show hierarchy in dropdown".

My vocabulary has the terms

a
-ab

and the only node is tagged with ab.

Now SBEF should show

a
-ab

but only shows

a

It appears that the module cannot handle taxonomy hierarchy filters yet.

Also I get an error message

Notice: Undefined index: field_name in Drupal\selective_better_exposed_filters\Plugin\better_exposed_filters\filter\SelectiveFilterBase::exposedFormAlter() (line 68 of modules/selective_better_exposed_filters/src/Plugin/better_exposed_filters/filter/SelectiveFilterBase.php).

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany demonde

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡«πŸ‡·France paul_leclerc Lausanne Switzerland

    @jrochate, it appears to me that using the field that targets the taxonomy as a filter only result to a textfield that required the term id.
    Its means that selective_better_exposed_filters needs verf β†’ module to works properly ?

  • πŸ‡΅πŸ‡ΉPortugal ricardofaria

    Having the same error after selecting "use only used terms". Using as filter criteria.

  • πŸ‡§πŸ‡ͺBelgium davidiio

    Hi everyone!
    We had the same problem using the module selective_better_exposed_filters trying to reduce the number of options of a "taxonomy term with depth" filter.
    I made small ugly patch.
    Noticing the $filter->definition['field_name'] could not be found and so the $field_id variable could not be set I have set it after using this code:

    if($field_id == NULL) {
       $field_id = $filter->options['reference_field'];
    }
    

    I guess a better approach would be to check if the filter is indeed a "taxonomy_term_with_dpeth" filter but I really could not find this info when inspecting the $filter variable :(

  • I am not having trouble with fields, but rather trying to reduce a term filter itself:
    (Taxonomy term) Taxonomy term: Term (exposed)

    This doesn't seem to work at all. I get the following:
    Warning: Undefined array key "field_name" in Drupal\selective_better_exposed_filters\Plugin\better_exposed_filters\filter\SelectiveFilterBase::exposedFormAlter() (line 68 of /var/www/html/web/modules/contrib/selective_better_exposed_filters/src/Plugin/better_exposed_filters/filter/SelectiveFilterBase.php)

    I have a custom entity with a term entity reference base field. Adding the filter from the field doesn't give the term settings, so you have to add it through the relationship to the term.

    Module doesn't seem to support that.

  • Status changed to Closed: won't fix over 1 year ago
  • πŸ‡ΊπŸ‡¦Ukraine stomusic Ukraine

    Sorry, but I see no possibilities to work with "Has taxonomy terms (with depth)" filter because current logic based on retrieving of results some reference field data and this filter missing any info about related field.

  • Status changed to Active 10 months ago
  • πŸ‡³πŸ‡±Netherlands willempje2

    TaxonomyIndexDepth is a bit different because it has the taxonomy_index table unlike other entities.
    Maybe we could utilize this instead of field references.

    See patch.

    There is some redundancy ( checking all related terms ) in here which could have impact on performance.
    In our cases this does not seem to give any issues.

  • πŸ‡«πŸ‡·France tostinni

    @willempje2 it seems to be working fine with 3.0.2.

    However we noticed that counting items was duplicated when we checked "Show hierarchy in dropdown".

    As branch 2.x is deprecated, I think we should move this issue to 3.x

  • Looking to resolve this exact same issue / need on our site.

    The patch is #10 is not working for me.

    The patch does enable the options to display for our taxonomy term with depth exposed filter, however no matter what settings i apply, all filter options are removed from the view when there are definitely valid options that should be showing.

    We're using solr search index and I believe I have enabled all of the correct field indexes but if there's specific settings that need to be enabled to get this to work, please advise. Getting this to work would be a massive help for what we're trying to do.

    We're on Drupal Core 10.3.9 and SBEF 3.0.3

    Thanks.

  • Was apparently on the wrong branch of SBEF, the patch does work! thank you!

  • @willempje2 So we've been working with this patch for a while and it certainly does what its supposed to with taxonomy (with depth) - we have ran into one issue with it, when "show option with item counts", the count is sometimes inaccurate, especially with larger counts.

    In one instance, the count says 40 but the actual items listed is 33
    In another, it says the count is 338 but the actual count is 184
    Also 194 but the actual is 132
    We have more examples but its definitely an issue.

    I suspect its from our hierarchy having a bunch of depth and potentially multiple tags appearing in the nodes. so the filter count is higher but the actual amount of nodes is much lower when duplicates are removed

Production build 0.71.5 2024