views:

1098

answers:

3

Background: Customer X has a CCK-based Content Type (vendorxxentry) and is using Views2 to generate a listing of all the vendorxxentry nodes in a simple table.

One of the fields in vendorxxentry is called "vendorxxattitude", which appears as one of the following enumerated possible values:

  • happy
  • sleepy
  • dopey
  • grumpy

Customer X has four custom-made 16x16 images that correspond to these enumerated values. He wants to have them display in the generated view, so instead of seeing "happy" in the generated view, the user would see the image happy.png in its place. Customer X would like to accomplish this without breaking the ability to sort individual columns as can be currently done with Views2 in table output mode.

Question: What methods would you use in order to substitute the text with the associated images? Assume that the images should only be substituted in one or more specific views (e.g., vendorxxsummary, vendorxxbyxxdate, vendorxxbyxxindustry), but not in the individual node views themselves.

+2  A: 

You can change the 'mood' from a simple data field to a taxonomy vocabulary, with each mood being a term in the vocabulary. Then use Taxonomy Image module to substitute an image for each mood in any way you like.

alxp
+1  A: 

I guess I would start by writing some kind of jquery that would find all the cells with those words and swap the Css around to move/hide the text and add your images as a background image. Much like the image replacement techniques people use for getting fancy fonts in headers. If you can do that without changing the underlying markup, it shouldn't affect the sorting mechanism?

Andrew
+2  A: 

I'd use the cool new Views 2 theming instead of installing a whole new module to handle one feature. Just figure out which field you want to theme and create a theme file with the appropriate name, and insert the default code from the theme information helper included with Views 2. Then, use a switch statement to theme the output appropriately.

This doesn't help the customer if they decide to add a field however, you'd have to update your code, but it will run a lot faster than a whole new module.

David Wees