- "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
- Announcements: Special Notices for Your Site
- Attendance Matrix
- Content Type Template
- FAQ_Ask
- Get Content Type
- Glossary
- Gotcha - Contact Spam Catcher
- Helpers
- Indexpage: summary of node type information
- Longer Node Titles
- Node Type Filter
- Quotes
- RealName: Using Profile fields to set a user's displayed name
- Register_Country
- Site Documentation Module
- Site Notes: Hidden Design or How To notes in Your Database
- Spam Tokens
- Spam Tune
- Taxonomy Browser
- Taxonomy Delegate
- Taxonomy Image: Associate Images with Taxonomy Terms
- Taxonomy List: Displaying Lists of Terms
- SBS Web Site Notes
- Searching for a New Hosting Company
- Taxonomy Tidbits
- Theming a Specific Content Type
Real Life Uses of Taxonomy Image
Submitted on Tue, 04/08/2008 - 18:22.
Any one who uses Taxonomy Image may feel free to submit their application here. Please contact NancyW.
Changing the standard taxonomy links
Many people have asked how to do this, so here's how I do it. As always, YMMV.
One of the groups that I maintain the siteA logically grouped set of content - also web site. for wanted a specialized newsletter. The articles are classified with a vocabulary and they asked for picturized links long ago. I modified the moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. for them by adding a hook_link_alter.
function pinkslip_link_alter(&$node, &$links) {
if ($node->type != 'pinkslip') { return; } /* only do ours */
foreach ($links AS $module => $link) {
if (strstr($module, 'taxonomy_term')) {
if (variable_get('pinkslip_display_term_list', FALSE)) { /* are we showing the terms? */
// Link back to my display and not the taxonomy term page
$tid = substr($module,14);
$term = taxonomy_get_term($tid);
$tname = $term->name;
$links[$module]['href'] = "pinkslip/term/$tid";
$links[$module]['attributes']['class'] = 'pinkslip_terms';
// See if we have a taxonomy image associated with this term
$taxo_image = taxonomy_image_display($term->tid);
if ($taxo_image) {
$links[$module]['title'] = $taxo_image;
$links[$module]['html'] = TRUE; /* if we don't do this, it will come out as text */
} /* end image insertion */
} /* end if display_term */
else { /* we don't want terms shown */
$links[$module]['title'] = ""; /* we'll just blank it out */
} /* end else */
} /* end if taxonomy_term */
} /* end foreach */
}In this example, we check to see if the linkThe technique which points to another page, anywhere on the Internet, from the current page. is from the taxonomy moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP.. If so, then we change the linkThe technique which points to another page, anywhere on the Internet, from the current page. to point back to the moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP.'s processing functions. There are several pieces to doing this as you can see. This code can probably be generalized for an entire siteA logically grouped set of content - also web site. without much difficulty.
There may be a better way to do this; I wrote it a long time ago when I was just beginning to write modules.
Now available! As I was writing up this example, it struck me that a lot of people might want something like this. So I sat down and generalized this code a bit and made it available as a contributed add-on feature for Taxonomy Image. When you download the TI moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. now, this code will be available for you to enable and select which types of nodes it should be used for. Enjoy!
Linking to Full Sized Image
In the Glossary moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP., I wanted the image to linkThe technique which points to another page, anywhere on the Internet, from the current page. to a full-sized image from the regular thumbnail, so I used the following code (simplified a bit).
if (module_exists('taxonomy_image') && $show_desc) {
$img = taxonomy_image_display($term->tid);
if ($img) {
$obj = taxonomy_image_get_object($term->tid);
$img = '<a href="'. $obj->url .'" target="_blank">'. $img .'</a>';
}
}A moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. usage matrix
I maintain somewhere around 16 sites, some live, some test sites. Each siteA logically grouped set of content - also web site. has its own set of contributed modules. During this time of transition from 5.x to 6.x, I needed some help keeping track of which modules have already been converted to 6.x so I know whether the siteA logically grouped set of content - also web site. can be converted.
I struggled for a while about how to organize and present the matrix. I played with the idea of using a vocabulary to define either the sites or the modules, but how to show whether the moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. was in use on a siteA logically grouped set of content - also web site., and if so, did it have an upgrade available yet. Suddenly it dawned on me that if I used Taxonomy Image's recursive image display I could create three main terms ("Available," "Unavailable," and "Unknown") and then place each moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. under one of those (single hierarchy). As the moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP.'s status changed, it would be a simple matter of changing its parent term. The recursive display feature allows me to define a single image for the parent terms and then each moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. under it would use that image.
This idea greatly simplified the whole process to the point that I could create the entire matrix in 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. page rather than create a moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP.. (Okay, for those militant no-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.-code-in-pages people, yes, I have the Util moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. and will probably go ahead and move the code there; but this is a completely isolated siteA logically grouped set of content - also web site. just for me.)
I created a new content type called "siteA logically grouped set of content - also web site." in which I could use the title for the siteA logically grouped set of content - also web site. name and the body for a brief description of the siteA logically grouped set of content - also web site.. The vocabulary attaches itself by saying that it pertains to the "siteA logically grouped set of content - also web site." type.
There was one small flaw though: I don't use the recursive feature on the siteA logically grouped set of content - also web site.. I also didn't want the wrapper division attached, which I do use on the siteA logically grouped set of content - also web site.. So I did what any self-respecting moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. developer would do: I changed Taxonomy Image to allow this. (Do I hear "Kobayashi Maru?"). While I was at it, I wanted to reduce the space needed, so I added a new feature to the Helpers moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. too.
<?php
$vid = 10; // <<---- the "modules" vocabulary.
$sites = array();
$sites = db_result_array(db_query("SELECT n.nid, n.title FROM {node} n WHERE n.type='site' and n.status=1"));
$terms = array();
$header = array();
$cols = db_result_array(db_query("SELECT tid, name FROM {term_data} WHERE vid=%d AND name<>'available' AND name<>'unavailable' AND name<>'unknown' ORDER BY name ASC", $vid));
$cols[0] = ' Site Name';
asort($cols);
foreach($cols as $tid => $name) {
$terms[] = $name;
if ($name == ' Site Name') {
$header[] = array('data' => '<strong>Site Name</strong>', 'align' => 'center');
}
else {
$header[] = array('data' => l(theme('vertical', $name), 'taxonomy/term/'. $tid, array(), null, null, false, true),
'valign' => 'top', 'align' => 'center', 'width' => '30px', 'class' => 'monospace vertical');
}
}
$rows = array($header);
foreach ($sites as $sitenid => $sitename) {
$row = array();
$cols = array_fill(0, count($terms), null);
$node = node_load($sitenid);
$desc = $node->body;
$cols[0] = l($sitename, 'node/'. $sitenid) .'<br/><small>'. $desc .'</small>';
$using = taxonomy_node_get_terms($sitenid);
foreach($using as $tid => $term) {
$i = array_search($term->name, $terms);
$img = taxonomy_image_display($tid, null, null, array('wrapper' => false,'recursive' => true));
$cols[$i] = array('data' => $img, 'align' => 'center');
}
$rows[] = $cols;
}
echo theme('table', null, $rows, array('border' => '1'));
?>I think it came out pretty slick. (Click on the picture to see it full size.) With Taxonomy Image inserting the term description into the "title" attribute, hovering over a mark tells me the status of the moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP.. Clicking on a moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. name at the top shows me all the sites using that moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP.. 
Adding the image to the title of a taxonomy/term/xx page
This was asked for as a support request. The user wanted to add the taxonomy image to the top of a taxonomy/term/xx page. This requires a bit of themeFor web sites, this refers to the "look and feel" of the site. It is also used to describe the code to produce that look. fiddling.
For information on changing your themes, I suggest the handbook section: PHPTemplate theme engine
- Create a copy of your page.tpl.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. and name it page-taxonomy-term.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..
- Locate where the title is being formatted (usually with an <h1> tag).
- Replace this line with this code:
- Save the code.
For example, Bluemarine has: <h1 class="title"><?php print $title ?></h1>
<?php if (module_exists('taxonomy_image')) {
$img = taxonomy_image_display(arg(2));
}
else {
$img = null;
} ?>
<h1 class="title"><?php print $img . $title ?></h1>
<div class="clear-block"></div>You should be in business now.



Recent comments
2 weeks 17 hours ago
2 weeks 17 hours ago
2 weeks 17 hours ago
2 weeks 17 hours ago
2 weeks 17 hours ago
3 weeks 4 days ago
4 weeks 5 days ago
6 weeks 4 days ago
7 weeks 3 days ago
10 weeks 16 hours ago