0

D7 question. I need to have a "clients" taxonomy with an image extra field on each term (the client's logo). Then I have a "project" content type. Projects belong to specific clients, ie the project content type has a term reference field to the client taxonomy.

When I click on a "project", I want to see the clients logo and not (only) the term name. This seems possible by following these instructions http://drupal.org/node/1224916, but this article is misleading: it suggests having an entity-reference field on the project content type instead of a term-reference. The problem with that approach is that when you connect a term and content by an entitity field, these two are not connected as far as taxonomy is concerned. So you lose all taxonomy functionality.

1

I beleive you can achieve this with the normal "Term reference" field, and a custom template file: field--field_my_custom_field.tpl.php in your theme folder which renders the image. You can access the value of your custom field through $items[$key]['#options']['entity']->field_my_custom_field where $key is the array index (if you have more than 1 value for this field, first item is index 0, second is 1 etc, usually you should just loop through the $items like foreach($items as $item) and then you can do $item['#options']['entity']->field_my_custom_field)

You may need to have a field.tpl.php (copy from root/modules/field/theme then duplicate it and rename the duplicate into field--field_my_custom_field.tpl.php) in your theme folder in order for it to work (or templates folder inside your theme folder, basically same folder as your custom field--field_my_custom_field.tpl.php) (Not 100% sure, but this was the case in Drupal 6)

API documentation for field.tpl.php

This may also come in handy: taxonomy-term.tpl.php

Sorry for unsure answer with a lot of unknowns, just trying to help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.