Posted by waltercat on May 18, 2008 at 8:27pm
| Project: | Taxonomy context |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
This is a great simple module for creating a category menu. On thing that would make it perfect for my needs is if there was a way to include the number of nodes per term in parenthesis after a term. Something like this:
Parent Term 1 (10)
-- Child Term 1 (5)
-- Child Term 2 (5)
Can someone advise how I would alter the code to reflect this.
Thanks!
Comments
#1
subscribe +1
#2
Here's a patch that optionally displays the number of nodes for each term. And since the two ideas are closely related, I've also added the ability to not display terms without any nodes associated with them. (I call them "empty terms.")
After applying the patch, there will be two new options in the configuration settings (admin/settings/taxonomy_context): "show term count" and "show empty terms." Term counts are disabled and empty terms are enabled by default, which results in pre-patch behaviour. You will have to go to the configuration settings and specifically enable these settings after you apply the patch.
I found when term counts are enabled, the default garland theme--maybe others, too--displays the term and count on separate lines in the context menu block for a specific vocabulary. I just changed garland's style.css section below from block to inline-block and it seems to be working fine.
ul li.leaf a, ul li.expanded a, ul li.collapsed a {display: block;
}
Please let me know how it works for you.
#3
I'm not able to patch this. I get:
Hunk #1 FAILED at 378.
Hunk #2 FAILED at 428.
Hunk #3 FAILED at 478.
Hunk #4 FAILED at 497.
Hunk #5 FAILED at 601.
Hunk #6 FAILED at 622.
Hunk #7 FAILED at 666.
Hunk #8 FAILED at 715.
What could be wrong? This seems like a very useful module. It would be great if you could commit changes to the module itself. Thanks.
#4
That's strange. Since I am new at this (contributing to Drupal module development), I thought I had messed something up. But I got it to patch fine.
Here's what I did:
patch < taxonomy_context_show_empty_terms_count_subterms.patchWould those be the correct steps to follow?
#5
Didn't work for me. Does the 5.x-2.x version include the patch?
#6
To everyone: Hmm, that's weird. Is anyone other than Vic96 having problems?
To Vic96: Would you like me to post my complete patched module? Unless someone else has ported it (and I doubt that's happened since I posted it a week ago), the 2.x-dev version does not include the patch. But if you would like to do that--or even commit the patch to the 1.x branch as you mentioned earlier--you're welcome to do so. I just don't think I'm quite ready to tackle that learning experience yet. (:
#7
Hi mr.neil,
I need this function to show only terms which have nodes assigned to. But I was also not able to patch the file. It would be great if you post the patched module.
Thanks very much for your contribution!
Jürgen
#8
How is the srcipt doing from a performance perspective?
Lets say I have a hieararchical category with 4-5 levels 30 000 terms and 200 000 nodes? :)
#9
Here is the complete patched module. (Replace the original module file with this one; be sure to rename the new file the same as the old one.) If anyone can figure out why it doesn't patch properly for some people, please let me know.
And giorgio79, I don't know the answer to your performance question. But could you try it for all of us who are curious and follow up? I'd be interested to know the results.
#10
Subscribing. greetings, Martijn
#11
i tried the module of #9 - i get a "page not found" in the administration area clicking the taxonomy context menu item?? my fault?
greetings momper
#12
now it works - sorry - cache?? it's not a long period test - but seems to work well for the moment ... :)
greetings momper
#13
#110374: Link's (node's) counter