By greta_drupal on
Haven't quite found a similar post with answer. But, if I overlooked, your link-to appreciated.
Story content type includes a CCK image field for uploading a thumbnail to appear with teaser.
Story content type also includes a taxonomy select for 'category' (used in other ways).
A specific thumbnail, already uploaded to server, corresponds with each category.
Example:
Category: State
Image: State Flag
How would I populate the CCK image field based on the category selected?
Or, is there a better way to automate the population of thumbnail field in db?
Thank you.
Greta
Comments
Check out the Image module
http://drupal.org/project/image
Not even close
While I appreciate your responding, I think that you missed the point (issue).
http://ItsAboutTyme.com
I'm assuming you want to show
I'm assuming you want to show an image next to lists of nodes, or teasers or something like that.
I'd do this at the theme layer, not by having a CCK imagefield. In the nodes template (node-node_type.tpl.php) just check the term, and output the html for the appropriate image. If it's a the output of a view, you'll have learn how to theme view output. You'll have something like
theme('image', 'path/to/your/image');
to print out the image html. You might look to contemplate module to get get your started, as it shows you all data you have at your disposal when theming a node.
This has the added advantage that if you want to change the image, you just replace the image file in one place, and don't have lots of copies.
Okay, not that I am well
Okay, not that I am well enough versed in PHP to code this out (I could spit this out in ASP in the time that it took me to type this) ...but I see the possibility.
http://ItsAboutTyme.com
Views???
I don't necessarily need to store the thumbnail with the node, so I was considering whether I could automate / call out the specific image in Views.
So, something along the lines of display fields: image = "/sites/files/icons/" & |taxonomy term| & ".jpg"
Can this be done in Views?
http://ItsAboutTyme.com
Yes. Except the field you
Yes. Except the field you want to display is "Taxonomy : Term". You're going to output the term, but instead of letting the default theme template handle it, which just prints the name of the term, you'll theme it yourself to show images.
1) Add the taxonomy term to your view's fields.
2) Click Theme : Information to see what template file is themeing the field. (probably views-view-field.tpl.php)
3) Make a note of other candidate template files. You need to pick one (e.g. views-view-field--name.tpl.php where name is the ID: shown for the field)
3) Copy the file from modules/views/theme that you found in 2, and copy it to your theme folder
4) rename it the the filename in 3. Click RESCAN in views. Views should now be using your new file.
5) Edit that file to theme how you want. Start with this to see what you've got to work with:
You'll likely have something like this in the end:
Awesome! Thank you for that
Awesome! Thank you for that big nudge. I will explore that option. I need a unique image ref for every COUNTRY, so using case would be pretty overwhelming. I'll need to 'automate' the file name by using a variable for the taxonomy term + ".jpg" .
I do this regularly in ASP; I'll just have to figure out the conversion.
http://ItsAboutTyme.com
you might also investigate
you might also investigate http://drupal.org/project/taxonomy_image
Holy cow, Batman! That looks
Holy cow, Batman! That looks like it will do the trick right out of the box. And, who doesn't love a good NancyDru mystery (solved). :-)
Okay, mtsanford, I do believe that you are my Drupal hero of the week, at least the week. [I Drupal searched this issue for a long time tonight, and never noticed that module.]
http://ItsAboutTyme.com