This patch integrates phptemplate with taxonomy_image module, by defining a new array usable for templates wich contains URLs to the categories images. It's only used if you've activate it in theme settings. I've added a patch to add a checkbox to this settings page [1].

[1] http://drupal.org/node/14027

CommentFileSizeAuthor
#2 phptemplate_engine_taxonomy_image.patch1.09 KBgrohk
phptemplate_taxonomy_images.patch1.43 KBAnonymous (not verified)

Comments

Anonymous’s picture

An example of use with box_grey theme: http://drupal.org/node/14029

grohk’s picture

StatusFileSize
new1.09 KB

I have applied this patch to the latest CVS phptemplate.engine and have attached a fresh copy of the patch.

I am testing this version of this patch on our website http://code0range.net

Is there any possibility that this could make it into the main phptemplate.engine or would that be a bad idea?

adrian’s picture

You can use an additional template.php file on a per template basis to include this functionality using :

[php

function _phptemplate_variables($hook, $vars) {
if ($hook == 'node') {
if (module_exist("taxonomy_image")) {
foreach (taxonomy_node_get_terms($node->nid) as $term) {
$vars['taxonomy_images'][] = taxonomy_image_display($term->tid, "alt='$term->name'");
}
}
}
}

?]

grohk’s picture

Made some small changes to the above code to make it work with the help of Adrian via #drupal-support IRC:


function _phptemplate_variables($hook, $vars) {
  if ($hook == 'node') {
    if (module_exist("taxonomy_image")) {
       foreach (taxonomy_node_get_terms($vars['node']->nid) as $term) {
        $vars['taxonomy_images'][] = taxonomy_image_display($term->tid, "alt='$term->name'");
       }
    }
  }
return $vars;
}

I am changing this to "by design" since this patch is not needed. The correct way to call the new variables in node.tpl.php is:

print $taxonomy_images[0]

Once I get this working really well I will add this to the documentation for the taxonomy_images module and the handbook.