So I'm working away on my site and grateful for the taxonomy_image module and then I come across a kink in the plans.

In my case I've got a number of different vocabs.
Podcasts
Authors
Blogs
Issues
etc.

and I'm creating a view to display a number of blogs. I want to display the 'Author's image next to the node i'm displaying.
no prob... just go into my view and select Taxonomy Image: Image works great.

but wait ... now my node has multiple vocabs it is selecting from. How do i tell the view to take only the author vocab picture. and only the first one (if i happen to have more than one term selected).

not sure how i would implement this and am hoping it may be a feature added to work with views.

love to hear your ideas if you have any on how to accomplish this.
thanks

Comments

nancydru’s picture

Status: Active » Postponed (maintainer needs more info)

I don't suppose you allow profile images that the author can upload and use the "Author Information" block from the profile module?

nancydru’s picture

Component: Code » Views
konsumer’s picture

If NacyDru's solution didn't solve (are the Authors actual users on the system? if so, enable profile, turn on user images in your theme settings.) The relationships you are describing do not seem to jive with that, though (there is only one author of a drupal node) so read on, if not...

I think there are a couple of data-modeling issues here.

Taxonomy-image defines a 1->many relationship (put all the images that apply to a thing in there) between taxonomy images and nodes. What you are describing is a many->many relationship, where multiple images are assigned to a single node, sometimes in the same category (Authors) but you only want to see only one (arbitrarily, the "first")

I think your data model for Authors and it's relationship to images and nodes is more complicated then what taxonomy image is designed for (Nancydru: I think you can better speak on this.) and there are alot of tools for doing this sort of thing with nodes, which might be better suited to serving as the the entities involved (Podcast/Issue with Authors - blog only has one author, who is actually a user of the system, so in that case use the above profile image)

Here is one way to solve:
Use something that makes more sense for your data model: CCK imagefields + node associations. Make a content-type that describes Authors, attach imagefield to them. Use some form of node-reference to pull Author information into Podcast display/editing.

Here are some ways to do that:

this compares 2 or 3 of them.

When choosing from several modules that you don't know, look at development activity, who developed it (do they write good code?) and do google searches for comparisons. This can sometimes be frustrating, and slow, so something you know may be a lot faster.

The last one has a drupal 6 version, and seems slightly more active, recently, so I'd probably look at that first, if the first option didn't work (I like to use as few modules as I can easily, and efficiently: Views and CCK is already installed...) Also, my brain hurts when I have non-standard, complicated relationships between nodes, and I have to juggle the weird specialized ways that a bunch of modules do some special little task. Sometimes it's the way to go, if things are simple, and it does just what you need (taxonomy_image will be that for alot of situations), but sometimes it's just better to break out your swiss-army knife and widdle something special (CCK+Views+theming fields/nodes/views can do just about anything, really)

In ronan's description of their module here, they say:

I have found though that if you find yourself trying to force a hierarchical structure onto your data in order to use this module, you might be better off using a more manual solution with node reference and views.

This may apply to your data model.

When I am working on data-modeling, in any language, or on any platform here's what really helps me, it may help you:

  1. draw little boxes representing things with arrows going 1 or 2 ways to show relationships. Write in any fields that the joins happen on, if that's important (not really here, everything is joined on nid, maybe field names...)
  2. Color code them if it's too much data (red for 1-many, blue for 1-1, green for many-1, etc)
  3. Find the absolute simplest way, that is manageable, to describe that relationship without "working against the tools", write pseudo-code if it needs some logic to manage it, or in this case: if it needs complicated theming/display options, stub out type-based theme pages with comments, or at least make little drawings of what the form/display fields should look like
  4. Make a throw-away version of drupal (or whatever the application base/framework/setup is) that you can just test ideas on. Try making a simple version that tests your ideas (don't invest alot of time)
  5. Look for all the places that it seems clunky, or over-engineered. If you find too many, try another idea. If you're doing it right, it should be simple and manage itself
  6. If you don't find too many bad spots, go back and fill it in, and polish it up. Copy it over to your dev site

This may be more then you need for a simple relationship, but when I start to feel like I have too many models floating in my head, that's what I do.

ridefree’s picture

wow ... thanks for the great response konsumer ...
tho i'm a little spoiled with great drupal community's ability to say .. oh hey there's a patch here just cut and paste this in here ;)

it is like you said...i had hoped to use profile images and bio info at one point but it just didn't make sense given that many of the writers are not on the system, and some items are written by multiple authors (a user is not necessarily an author)

i had seriously considered using a cck content type with something like node hierarchy ... but at the time had found taxonomy to fufill my needs with the image etc. and while a little clumsy for the ui i would have to teach the staff, felt it would at least keep things simple in a certain way.

But of course, down this loose development path, new ideas and requests come in that seem simple to add but .... :-)

it may be a little late at the moment for me to go back to the planning advice you mentioned... but I've learned a lot and will make better use of it in future projects. :-)

I guess my question now will be whether it makes sense to have some of the developers i work with build some sort of patch for the taxonomy images view capacities. or whether to back off on some of the items i was trying to accomplish :)

thnx for the help

nancydru’s picture

TI does not, and probably never will, allow more than one image for a single term. You may, however, select multiple terms, each of which may have an image.

Actually, to be more precise, a given node may only have one author at a time. Each revision (if you use that feature) may have a different author and they could all be retrieved with a bit of creativity (as I do in IndexPage).

I have a similar need on one web site and solved it by creating blocked user accounts for the non-member authors. Kind of hokey, but it works for me since I have very few of them.

ridefree’s picture

hey nancyDru ...

thanks for the thoughts. I think my node terms are a little misleading though, in what i'm trying to accomplish.
forget one is called author (the standard author field is not in use here, as there are only a few staff posting content from 100's of different authors :)

my situation is that I have:

- a content type with
- more than one vocabulary attached

a node of this content type may choose multiple terms from some of these vocabs.

so i could get a node with 2 terms from vocab 1, 1 term from vocab 2, and 7 terms from vocab 3

which all works well. and I have images associated with lots of the terms from different vocabs.

my issue/feature request is that when I am creating a view to display all nodes of a certain criteria
i'm keen to show each node with an image beside it that is from a term of (let's say) vocab 1.

for design and clarity sake I only want to show one image, and from the same vocab.

when i go to create a view and 'add a field' .. i can choose Taxonomy Image: image which is the image associated with the term of the node.

but as you can see I have several different terms from different vocabs associated with it.

what I think would be great (without knowing how to go about doing any of the coding) is that in this FILTER that comes from the Taxonomy Image, have the ability to select what vocab(s) you want to take the image from. (under the handler or?)

ANd for bonus points: select how many images should appear if there is more than one.

:-) So that's my feature wish. Hope it's clearer. If i figure out a decent solution to accomplish what I want I'll post here, but atm I am just putting limits on what items get images.

nancydru’s picture

Well, I can maybe give you some theme code that can be modified to do this.

nancydru’s picture

Status: Postponed (maintainer needs more info) » Postponed
nancydru’s picture

I'm not sure that filtering on an image makes sense. You can, however, filter on terms already. Doing that should limit which images are displayed.

nancydru’s picture

Status: Postponed » Postponed (maintainer needs more info)
ridefree’s picture

hey nancydru ...

been swamped with some other projects, but this issue is still at large on our site.
hoping to get back to it in the next several weeks. will look through your advice again with fresh eyes and see if I can come up with anything new.

-brian

nancydru’s picture

A patch would be wonderful. I have learned more about Views2 recently, but am far from what merlinofchaos (Earl) would even classify as a "beginner." I might be able to fix this now for you, but am afraid I might break everyone else's site. I am sort of drawn back to konsumer's suggestion of using Image Attach in your case.

nancydru’s picture

Status: Postponed (maintainer needs more info) » Postponed
siliconmeadow’s picture

Here's a theme snippet you can use which seems to work ok for me:

<?php
$termarray = taxonomy_node_get_terms_by_vocabulary($nid,6);
  foreach($termarray as $ta) {
    $imgtid = $ta->tid;
  }
print taxonomy_image_display($imgtid);
?>

The integer "6" above is $vid - the vocabulary ID. Change to suit your installation.

taxonomy_node_get_terms_by_vocab is documented here:

http://api.drupal.org/api/function/taxonomy_node_get_terms_by_vocabulary/5

Your mileage may vary. HTH.

pomliane’s picture

Status: Postponed » Closed (won't fix)

This version of Taxonomy Image is not supported anymore. The issue is closed for this reason.
Please upgrade to a supported version and feel free to reopen the issue on the new version if applicable.

This issue has been automagically closed by a script.