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

momper’s picture

subscribe +1

mr.neil’s picture

Status: Active » Needs review
StatusFileSize
new4.77 KB

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.

Vic96’s picture

Component: User interface » Code

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.

mr.neil’s picture

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:

  1. I downloaded the patch file I attached to my earlier message.
  2. I downloaded Taxonomy Context version 5.x-1.0 or 5.x-1.x-dev from the project page and extracted the files. (Version 5.x-2.x-dev will not work with this patch.)
  3. I copied the patch file to the directory that was created when I extracted the module files.
  4. Using the command line, I navigated to that directory and ran this command:
    patch < taxonomy_context_show_empty_terms_count_subterms.patch

Would those be the correct steps to follow?

Vic96’s picture

Didn't work for me. Does the 5.x-2.x version include the patch?

mr.neil’s picture

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. (:

humanoid’s picture

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

giorgio79’s picture

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? :)

mr.neil’s picture

StatusFileSize
new24.5 KB

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.

summit’s picture

Subscribing. greetings, Martijn

momper’s picture

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

momper’s picture

now it works - sorry - cache?? it's not a long period test - but seems to work well for the moment ... :)

greetings momper

nancydru’s picture

Status: Needs review » Closed (duplicate)