I have a hierarchy where the nodes can have a end term but not it's ancestors, so the count doesn't work for me and neither the feature of hide unused terms.
So I made a patch to include the count of descendants.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | taxonomy_menu-node_count_children_1064510_19.patch | 3.77 KB | SilviuChingaru |
Comments
Comment #1
dstolThanks, why don't you reroll it with an administrative option to include descendants or not.
Comment #2
john.money commentedThe original patch works but then makes the taxonomy_term_count_nodes() call redundant. My attached patch does a couple things:
Here's a chart of possible options. There may be more permutations:
Patched against 6.x-2.x-dev (2011-Dec-02).
Comment #3
john.money commentedChanging status to needs review
Comment #5
johnvMarked #1337012: hierarchical taxonomy counts as a duplicate.
It contains a different solution. Not sure if it is better or compatible:
somewhere in function _taxonomy_menu_item there should perhaps be something like this:
this way, the parent terms menu items of a hierachy will have a number that is the sum of the count of the children instead of (0) as is now.
Comment #6
johnvThese are duplicates, but have different solutions to the problem:
#1064510: 'Display number of items': Node count should include descendants
#784022: 'Display number of items': (incl. child terms), but do not group descendants
Comment #7
stewart.adam commentedAttached patch adds a new checkbox "Include items belonging to child terms in number counts" (defaults to disabled) which enables the inclusion of child terms' items in the node count.
Comment #8
Aurous commentedPatch by stewart.adam works perfectly fine.Comment #9
Aurous commentedPlease ignore previous post - one issue I am facing with stewart.adam's patch is that if the term reference node is deleted - the counter doesn't change for parent term, but only changes for child term.
Comment #10
stewart.adam commentedTo make sure I understood correctly:
In this scenario deleting Node 2 updates the counter for the Child but not Parent term?
Comment #11
L.A. commentedThe patch #7 is only working for the first child...
Eg. if I have this structure (standard "display number of items"):
the patch shows "Main (10)", so it doesn't count SubSub1 and SubSub2...
Besides this, I think the number of items should be shown like this:
Comment #12
slurpee commentedHello from Drupal's GSoC 2014 team. Google Summer of Code (GSoC)? - an annual program for university students organized by Google with projects managed by open source organization mentors such as us (Drupal!).
We're currently browsing the issue queue looking for projects. Do you think this issue/project is worth a student spending a summer on it and being paid by Google? If so, are you interested in mentoring the student? Learn more about Summer of Code and how to get involved at links below. We're submitting our Summer of Code application to Google in just over 24 hours and looking for last minute ideas. Please respond quickly if you're interested.
Group to join - https://groups.drupal.org/google-summer-code
Ideas for projects for Summer of Code 2014 - https://groups.drupal.org/node/404778
GSoC Homepage http://www.google-melange.com/gsoc/homepage/google/gsoc2014
Google's Summer of Code 2014 Announcement - http://google-opensource.blogspot.com/2014/02/mentoring-organization-app...
Comment #13
parasolx commentedThis patch already in 2 years ago and none of solution come out to let it commit in current version. Or does it plan to move into new major version?
I patch and it works successfully.
Comment #14
zionduc commentedHello,
I'm just thinking if taxonomy_get_tree() wouldn't be better instead of taxonomy_get_children()?
So
instead of
Comment #15
Yuri commentedAny updates here?
Comment #16
Anonymous (not verified) commentedPatch #7 worked for me on current dev, with a litle difference in lines. I am not a coder, maybe someone can make a new patch?
Why is the status 'needs work' and not 'needs review'?
Comment #17
rimen commentedMy patch.
New option like in #7 with correct update node counts in parent terms (see #9)
Before mark as tested this logic must moved in taxonomy_menu_translated_menu_link_alter() allso.
Comment #18
makbay commented#17 worked for me and I applied the same logic into function taxonomy_menu_translated_menu_link_alter() and it also worked.
Comment #19
SilviuChingaru commentedMade patch from #17 apply against latest dev version. Applied the same concept to taxonomy_menu_translated_menu_link_alter().
Comment #20
SilviuChingaru commentedComment #21
chris matthews commentedWould it be possible to commit the patch in #19 to 7.x-1.x-dev and tag a 7.x-1.6 release? Maybe some of the patches that need review can get in this release as well.
Comment #22
andrey.troeglazov commentedComment #24
andrey.troeglazov commentedFor me its ok, I have commited the last patch but will be good if smn can double check it.
Comment #25
andrey.troeglazov commented