This patch will allow users to show the number of nodes after each term, in parenthesis, like this: "Term A (4), Term B (10)", etc. It will add a new check-box option 'Show term node count' under 'Configure filter' options.
This patch is against the 6.x-2.0-beta1 version.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | better_exposed_filters_V2.patch | 2.84 KB | ressa |
| better_exposed_filters.patch | 2.83 KB | ressa |
Comments
Comment #2
ressaPatch with 'diff --git' in stead 'diff -ruN'.
Comment #3
mikeker commentedBrilliant! Thanks for the patch!
Committed with a small change to limit this feature to Taxonomy-based filters.
(FYI: the test-bot was barfing on your patch because of trailing whitespace that Git doesn't like.)
Comment #4
mikeker commentedPorted to BEF 6.x-3.x. Also added term counts to radio buttons, both for D6. Still needs D7 port.
Comment #5
mikeker commentedTurns out that taxonomy_term_count_nodes has been removed from the D7 API. See the discussions related to this:
#602240: Re-add taxonomy_term_count_nodes()
http://drupal.org/update/modules/6/7#taxonomy_node
And a possible solution: #603868: Rework Term Node Count for D7.
So this will remain a D6-only feature. And I should point out that it only works accurately if there are no other filters applied because it simply does a database lookup and does not include the current exposed filters.
I need to add text to the option describing its limitations, leaving as "needs work" until I do.
Comment #6
ressaYou're welcome, I am glad my patch made it into the module! Thanks for also adding term counts to radio buttons. Where was the trailing white-space(s), just in case I submit another patch in the future?
Too bad that taxonomy_term_count_nodes is not included in the D7 API, let's hope it gets included eventually. Until that happens, a temporary solution might be to copy the taxonomy_term_count_nodes function from D6, upgrade it to D7 and include it in the BEF module?
Comment #7
mikeker commentedI don't know, actually, that's just what Git was complaining about. You might check to see if your code editor has an option to remove trailing whitespace on save...
My concern is that folks will think this is a poor man's faceted search option, which it isn't since it doesn't reflect the settings of the other filters, just the node count of the term from the database. And I don't want to start adding additional search options to BEF. I figure that Views does a far better job of that than I!
Comment #8
quasi commentedIs this functionality going to be available for D7?
Comment #9
mikeker commentedNo. The API call that returned the number of nodes/term was removed from Drupal core due to performance reasons. This will not be ported to D7 unless a performant replacement function is made available.
Tagging as needs docs as I still need to update the BEF docs about the limitations and performance implications of this option.
Comment #10
halloffame commentedChangelog for the latest 6.x-3.x-dev indicates that this patch has been committed but I can't seem to see the supposed 'Show term node count' anywhere.
Comment #11
mikeker commentedIn hindsight, this was a poor addition to BEF as the Drupal core function that it relies on is such a performance hit that it was removed from core in D7. Look into the Search API and Facet API modules to incorporate this functionality into Views' exposed filters. Once you can see these options in Views' stock exposed filters, the BEF can tweak those options.
Comment #12
halloffame commentedI hope you could still leave this route open to achieve this functionality for smaller sites on D6 regardless of the performance hit of taxonomy_term_count_nodes() as it will be too much for us to use other Search Backends just to achieve this functionality.
Having said that, this patch works accurately without any other filters. Is there any chance you could make this respect filters based on arguments and display the appropriate count according to the current arguments?
You see I have a Node View based on term argument -- Category 1, Category 2, etc. My exposed filter which I intend to append the node count is from another vocab. When I'm in mysite.com/category1 the count on these exposed filters does not respect the argument filter thus displaying inaccurate count that remains the same no matter what category I'm in.
Comment #13
mikeker commentedThere is no new work going into the 6.x branch at this time. I'm happy to review and commit patches but can't provide any new work here.
Sorry.