How can taxonomy images be handled under 4.6? I see the taxonomy image module doesnt appear to be updated. Thoughts, suggestions?

Comments

jesusphreak’s picture

This interests me as well. I'd like to be able to have a little picture beside each story on the frontpage, relating to what category it is in.

red_eye’s picture

Well I answered my own question. The module worked fine with just pretty much the usual mods to the theme files. More info here http://drupal.org/node/23439

jesusphreak’s picture

Looks good. I suppose it doesn't work with phptemplate, though.

red_eye’s picture

Sure, you just have to make the right mods. Log into my site(you can use your drupal.org login) and try switching to some of the php templates. Now granted I just hacked it in so its not neat and needs its own style etc, but it works. I doubt youd have too much trouble.

grohk’s picture

In your template.php file add this function:

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;
}

Once you have that function in your template.php, you can call the new variable in node.tpl.php like this:

print $taxonomy_images[0]

---
Code0range: Drink Your Juice

red_eye’s picture

Thanks grohk, much better than the hack I pieced together. Nice site too!

jesusphreak’s picture

Apparently this doesn't work.

I followed all the instructions, but upon trying to upload an image, I get this message:

Fatal error: Call to undefined function: check_query() in /home/richeswi/public_html/drupal/modules/taxonomy_image.module on line 320

EDIT: This wasn't too difficult to fix. A quick search found that check_query has since been replaced in Drupal by db_escape_string.

If this is to be updated, this is the one thing in the codebase itself that needs to change.

laura s’s picture

The line you cite was committed to the module some months ago. Line 320 now reads:

      $values[] = (string)db_escape_string($edit[$field]);

So the 4.5.2 module as-is works for 4.6? That's great news! I had not thought to try it.
===
Laura
pingV

_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet

jesusphreak’s picture

Speaking of this module, I'm having a bit of a problem.

I've got an image right beside a paragraph.

Basically, it looks something like this:

<p>text</p><img src="/example" />

But what ends up happening is the image displays below the paragraph, when I want it to display beside it.

What CSS can I use to get the image to display to the immediate right of the paragraph?

Thanks :)

laura s’s picture

Float: right your img tag. But that will float all images. Maybe you don't want that. If you want to be more targeted, give it a div tag in the template first:

<div class="taximg"><?php print $taxonomy_images[0] ?></div>

Then in your css:

.taximg {
     float: right;
     margin: 5px 5px 5px 10px;
}

And you're set. (The padding is so you don' t have text flush against the image. You may want to play with that, depending upon your layout.)

===
Laura
pingV

_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet

jesusphreak’s picture

Works fine under 4.6.2...

I don't understand why this is still lingering in the CVS. It works fine in the 4.6 series. Its just a matter of editing the theme engines/themes to get it to work, but there's not a thing wrong with the module itself.

pamphile’s picture

not working here - I don't have an file called template.php