- "Ask the Expert" or Advice Column
- "Must Have" Modules
- A Challenge
- Books Overview
- Changing Garland - A Practical Example
- Comparison of Links and Web Links modules
- Create Simple Tables
- Creating a "Biographies" page
- Developing a Module on a Windows System
- Generic Table Display
- How to page a custom DB query
- List Users From a Single Role in a Block
- My Modules
- SBS Web Site Notes
- Searching for a New Hosting Company
- Taxonomy Tidbits
- Theming a Specific Content Type
Content Count by Taxonomy Term - Pager Version
Submitted on Wed, 10/03/2007 - 14:25.
$vid = 1; // <<--- put correct vocabulary number here
$terms_per_page = 10; // <<--- put number of terms per page here
$vocab = taxonomy_get_vocabulary($vid);
echo '<h2>Usage of "'. $vocab->name .'" Category by Term and Content Type</h2>';
if ($vocab->description) { echo '<h6>'. $vocab->description .'</h6>'; }
Usage of "Changelogs" Category by Term and Content Type
These are Change log "blogs" for my modules. The module entries (terms) themselves contain links to the appropriate project page, or page on my site, and Drupal.org "Contributed Modules" handbook pages.
| Term | story |
|---|---|
| Attendance Matrix This provides a table view of who attended which meetings. Project page | Documentation page | Change log | 1 |
| FAQ_Ask This module is an add-on to the FAQ module that allows users with the 'ask question' permission to create a question which will be queued for an 'expert' to answer. Project page | Documentation page | Change log | 14 |
| Get_Content_Type The get_content_type module fills an oversight by the D5 developers. When they moved the part of CCK (sometimes called CCK-Lite) into core for creating new content types, they forgot the analog to taxonomy/term/xxx, that is node/type/xxx. This simple module provides that function. This module has not been contributed due to disparaging comments from more advanced Drupallers. Project page & Documentation | 1 |
| Glossary The glossary module scans content for glossary terms (including synonyms). The glossary indicator is inserted after every found term, or the term itself is turned into an indicator, depending on the site settings. By hovering over the indicator, users will see the definition of that term displayed as a "tool tip." Clicking the indicator leads the user to that term presented within the whole glossary or directly to the detailed description of the term, if available. Project page | Documentation | Change log | 25 |
| Gotcha Gotcha intercepts the Contact form submission and checks an inserted hidden field to catch spambots. If something is there, Gotcha simply returns to the front page and ignores the message. The attempt is logged and saved in the database. If the field is empty, then the message is scanned by the Spam module, which has very good filters for catching spam. If everything looks okay, the message is passed on through to the Contact module for normal processing. Project page | Documentation | Change log | 8 |
| Helpers Helpers is a collection of functions to help developers work smarter and faster. Project page | Documentation page | Change log | 8 |
| Longer Titles Drupal 6 changed the length of the title field for nodes to 255. This module brings that change to version 5.x. Project page | Documentation | Change log | 2 |
| Node_Type_Filter This is a simple module that allows for various lists, such as "taxonomy/term," to be filtered by content type. Project page | Documentation page | Change log | 4 |
| Register_Country Are you creating a country portal or a site dedicated to a specific country? The Register Country module is designed to intercept new registrations and check if the IP address being used is registered to a country that the site administrator has chosen. In this way, you may limit sign ups to your site to specific countries. Project page | Documentation page | Change log | 1 |
| Site Documentation To simplify it a bit, the Site Documentation module picks up information from various places within the Drupal environment. Some of the information comes from internal arrays, some is derived from system calls, and some comes directly from the database tables. This information is pulled into a report that can be used to document the site. In addition, it will detect some problems that may exist in your installation, and optionally correct them. Project page | Documentation page | Change log | 39 |
And here's the code:
<?php$vid = 1; // <<--- put correct vocabulary number here
$terms_per_page = 10; // <<--- put number of terms per page here
$vocab = taxonomy_get_vocabulary($vid);
echo '<h2>Usage of "'. $vocab->name .'" Category by Term and Content Type</h2>';
if ($vocab->description) { echo '<h6>'. $vocab->description .'</h6>'; }
$header = array(t('Term'));
$rows = array();
$type = array();
// Build header row with types.
foreach ($vocab->nodes as $key => $value) {
$type[] = $value;
$name = $value;
$header[] = array('data' => $name, 'align' => 'right') ;
} /* end foreach */
$results = pager_query('SELECT * FROM {term_data} td WHERE td.vid='. $vid . ' ORDER BY td.name ASC', $terms_per_page);
while ($term = db_fetch_array($results)) {
$line = array();
$line[] = l($term['name'], 'taxonomy/term/'. $term['tid']) ."<br/><small>". $term['description'] ."</small>";
foreach ($type as $content_type) {
$count = taxonomy_term_count_nodes($term['tid'], $content_type);
if ($count) { // Don't show terms with 0 count.
$line[] = array('data' => $count, 'align' => 'right');
} // End if count.
else { $line[] = ' '; }
} /* end each content_type */
$rows[] = $line;
} // End while term.
if (!count($rows)) { $rows[] = array('data' => 'No terms found.', 'colspan' => '100'); }
echo theme('table', $header, $rows);
echo theme('pager', $terms_per_page);
?>



Content Count by Tax Term - Your Code
Hi Nancy,
I've communicated with you a couple of times, and you've been very gracious with your help. I have a question about your code to using your taxonomy/category tools (you call them taxonomy snippets):
If you create a file and put your code into it, then save it to your siteA logically grouped set of content - also web site., do all I need to make it work is a linkThe technique which points to another page, anywhere on the Internet, from the current page. on my navigation menu? Or how does it get executed?
On another point, is there a way to modify your code so that a user can select which taxonomy (category) terms to search, count instances, and then present in a table as this example does? In this way, instead of presenting all available category terms, you could choose to select specific ones.
Thank you in advance for any advice.
Sincerely,
-George Bradford
Snippets
If you create a PHPRecursive acronym for "PHP: Hypertext Preprocessor" - is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.-formatted node (story or page) with your code, then, yes, all you need is a menu item to make it work. You may also include the code in a moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP..
It is possible to intercept a "taxonomy/term/aaa,bbb,ccc" URL and do whatever you want. I don't have any examples at hand. Possibly the Taxonomy Redirect could send you into one of these snippets.
It certainly gives me an idea to add to my "tidbits" moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. if I even get it finished and published.