By jesusgeek83 on
Hey everyone,
I'm planning on making a taxonomy that will simply have the terms "yes" and "no". The taxonomy will relate to if a Rosary is given away or left at a given geocache visited by one of my users.
Ok, now to the real question. Is there a way to obtain a count of how many nodes are in the "yes" term and then make a block using that count?
Basically, is it possible to make a block that says "X Rosaries Given Away" X being the amount in the yes term of the Rosary taxonomy.
Thanks
God Bless,
Chris
Comments
Pretty simple
Nancy W.
now running 5 sites on Drupal so far
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in Your Database
NancyDru
Thanks, will give it a go!
Thanks, will give it a go!
Looks like that will work.
Looks like that will work. Is there a way I can do the same thing with amount of terms in a given taxonomy and for the amount of users on the site? I am now thinking that doing a statistics page might be a better move than putting the information on the front page.
I am assuming you could just change some of the code to do that but, I wouldn't know what to change...
Here's a taxo sample
Nancy W.
now running 5 sites on Drupal so far
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in Your Database
NancyDru
Pretty neat! Is there a way
Pretty neat! Is there a way to make it so that you just get a number of terms in the taxonomy, without listing them? Also, I seem to be getting a conflict with one of my modules. Could there be a variable being used with the same name in the module? In which case, can I change the variable names in the PHP code?
Here is the error I am getting:
warning: Invalid argument supplied for foreach() in c:\hosting\webhost4life\member\ctlw83\modules\profile\geocaching\geocaching.module on line 108.
Thanks again for all of your help!
God Bless,
Chris
Absolutely
Good thing you reminded me, because I'm so tired I almost forgot about this function:
taxonomy_term_count_nodes(nnn)where nnn is the term number.As long as the variable is not used in the same function, it should be okay. But the code I gave you would be better in a page rather than a module.
Nancy W.
now running 5 sites on Drupal so far
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in Your Database
NancyDru
Views integration
Is there any way to show this value in views?
I think you should use the
I think you should use the function taxonomy_term_count_nodes(). I didn't know that such a API function exists. So I took your initial function and realized that hidden nodes are also selected because the query doesn't take care about status = 0. So I came up with the following function:
Then I found taxonomy_term_count_nodes() which makes it easier - the whole query can be replaced. So I think one should use taxonomy_term_count_nodes(). What do you think?
Yes
Yes, you can use taxonomy_term_count_nodes, but be aware that it is known for being less efficient. BTW, there is nothing wrong with including "status=1" directly in the query - it need not be a substituted parameter.
NancyDru
This little modification is
This little modification is for to create a link to the term
Group by pivot?
Can the above code be modified to provide a pivot table to analyse term counts? For example count of terms by immediate book parent/ root parent.
Perhaps a view might be more appropriate?
CCK Computed Field
Is there any way to store this value in a CCK Computed Field? Thanks.
Hi, I was wondering if its
Hi, I was wondering if its possible to show a count of how many *terms* there are in a certain vocabulary.
For example, I've used the code found elsewhere to say, "There are currently XXXX number of nodes in our database." I'd like something to say, "There are currently XXXX number of nodes filed under XXX subjects in our database."
I don't know PHP all that much, so I need some help, if anyone is willing to offer it.
Thanks.
Term Node Count keeps track
Term Node Count keeps track of node counts for all terms and gives that data to Views, which can be used in a block.
bookmark
bookmark