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.
Hello,
I wrote a facet filter plugin to only show items from a specific depth of a hierarchical set of facet items. It's actually quite similar to the 'Show only deepest level items' filter that comes with facetapi_bonus, except you get to specify the depth. I thought it might be useful for other people to use so I here's a patch. (e.g. #1493326: Split hierarchical taxonomy in multiple facets.)
Let me know what you think!
Thanks!
drclaw
Comment | File | Size | Author |
---|---|---|---|
#16 | facetapi_bonus-add_a_filter_plugin_to-2056099-16.patch | 3.89 KB | thePanz |
Comments
Comment #1
brechtvdv CreditAttribution: brechtvdv commentedThe new file should be included in the .info file.
files[] = plugins/facetapi/filter_show_items_from_specific_depth.inc
Comment #2
drclaw CreditAttribution: drclaw commentedAh yes, my mistake. Here's a new patch.
Comment #3
Daniel Schaefer CreditAttribution: Daniel Schaefer commentedHi drclaw,
I really need this functionality too so thanks for you effort!!
However, I applied the second patch using Ubuntu console but I get the following error in Drupal backend:
Fatal error: Class name must be a valid object or a string in /sites/all/modules/facetapi/facetapi.admin.inc on line 875
I checked and all the right files seem to have patched correctly. Any idea on the cause for this error?
Comment #4
drclaw CreditAttribution: drclaw commentedDid you try a cache clear?
Comment #5
Daniel Schaefer CreditAttribution: Daniel Schaefer commentedHa. Of course!
Works like a charme for now, thanks.
Comment #6
stijndmd CreditAttribution: stijndmd commentedHi drclaw,
This patch in combination with the snippet provided by cpliakas over here: https://drupal.org/node/1493326
was exactly what I needed.
I have set up everything.
I get the options provided by this plugin.
But as soon as I select '1' or '2' under "Only show items from this depth of a hierarchical set of facet items", the facetblocks disappear.
Any idea what I might be missing?
If I leave '0' as term Depth, both term depths are shown in the facetblock.
The Term Depth module is enabled, but when I look up my terms in the database, there are is no Depth column anywhere.
My terms are structured in two depth levels though.
EDIT:
in the taxonomy_term_hierarchy under column "parent":
for each term, the [tid] of the parent is listed tho.
Comment #7
Omar AlahmedThank you very much, it's working perfectly.
Comment #8
marcoka CreditAttribution: marcoka commentedused the patch. works. remember to clear APC cache or you get an error.
Comment #9
codev0 CreditAttribution: codev0 commentedHi.
Does not apply the patch
Comment #10
vikramy CreditAttribution: vikramy commentedI have tested this and works great.
@dakanca, I also got same error but manually updated .info file.
Comment #11
Koen.Pasman CreditAttribution: Koen.Pasman commentedI've tried the patch on the stable release as well as the development release, but in both cases I receive this error:Fatal error: Class name must be a valid object or a string docroot/sites/all/modules/contrib/facetapi/facetapi.admin.inc on line 912
. This means a similar error as in #3.As mentioned I need to clear the APC cache, but in my environment APC is not active, so no cache could be cleared. Ofcourse I tried the usual: drush cache-clear and drush registry-rebuild but no success. For some reason the new class does not get included and/or a reference in the settings array is missing.Edit: ofcourse, just as I posted this I saw that the patch placed the filter_show_items_from_specific_depth.inc in the Facet API module instead of the Facet API Bonus module.. Moving it the correct folder fixed the issue.
Comment #12
vikramy CreditAttribution: vikramy commentedIt looks like this patch works fine on 7.x-1.x branch.
Comment #13
Koen.Pasman CreditAttribution: Koen.Pasman commentedYes, you are correct, as soon as I posted my comment I found out that applying the patch placed the
filter_show_items_from_specific_depth.inc
file in thefacetapi
module instead of thefacetapi_bonus
module.Comment #14
ptmkenny CreditAttribution: ptmkenny commented@Koen.Pasman (#13) You are mistaken; the patch places a file in the facetapi directory of the facetapi_bonus module, but it places no files in the facetapi module.
Comment #15
vegardjo CreditAttribution: vegardjo commentedThis works, except I get the same bug as @dakanca and @vikramy, where the .info file is not updated with the new file reference. I edited this file manually, and after that the patch works as advertised. Thanks, I think this is a very good addition to the module!
Comment #16
thePanz CreditAttribution: thePanz at Liip for FREITAG lab. AG commentedRerolled patch, minor fixes for new-lines.
Patch has to be applied to 7.x-1.x branch
Comment #18
thePanz CreditAttribution: thePanz at Liip for FREITAG lab. AG commentedPatches merged and committed, thanks all! :)