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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

brechtvdv’s picture

The new file should be included in the .info file.

files[] = plugins/facetapi/filter_show_items_from_specific_depth.inc

drclaw’s picture

Ah yes, my mistake. Here's a new patch.

Daniel Schaefer’s picture

Hi 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?

drclaw’s picture

Did you try a cache clear?

Daniel Schaefer’s picture

Ha. Of course!

Works like a charme for now, thanks.

stijndmd’s picture

Issue summary: View changes

Hi 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.

Omar Alahmed’s picture

Thank you very much, it's working perfectly.

marcoka’s picture

used the patch. works. remember to clear APC cache or you get an error.

codev0’s picture

Hi.

Does not apply the patch

patch -p1 < facetapi_bonus-filter_depth-2056099-2.patch
patching file facetapi_bonus.info
Hunk #1 FAILED at 11.
1 out of 1 hunk FAILED -- saving rejects to file facetapi_bonus.info.rej
patching file facetapi_bonus.module
vikramy’s picture

Status: Needs review » Reviewed & tested by the community

I have tested this and works great.

@dakanca, I also got same error but manually updated .info file.

Koen.Pasman’s picture

I'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.

vikramy’s picture

It looks like this patch works fine on 7.x-1.x branch.

Koen.Pasman’s picture

Yes, 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 the facetapi module instead of the facetapi_bonus module.

ptmkenny’s picture

@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.

vegardjo’s picture

This 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!

thePanz’s picture

Rerolled patch, minor fixes for new-lines.
Patch has to be applied to 7.x-1.x branch

  • thePanz committed d1e3853 on 7.x-1.x
    Issue #2056099 by drclaw, thePanz: Add a filter plugin to only show...
thePanz’s picture

Status: Reviewed & tested by the community » Fixed

Patches merged and committed, thanks all! :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.