drupaldrupal-7drupal-taxonomydrupal-field-api

Displaying content of term reference instead of link (Drupal 7)


I need help with this Drupal 7 situation:

And here is my problem. I've added a new term reference field named "field_hotel", but I only get a link to taxonomy term instead of actual content.

I tried to use this code, entity_load() runs fine, but I get "EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids()" error in field_view_field(().

$term = entity_load('taxonomy_term', array($hotel["und"][0]["taxonomy_term"]->tid));     
$view = field_view_field('taxonomy_term', $term, 'field_hotel');    
print render($view);

What am I doing wrong?

Thank you for your answers


Solution

  • Instead of storing hotel information in taxonomy terms, I'd suggest that you create a separate content type for hotels. That way, you'll be able to link offers to hotels using References, which is a much more flexible approach. That will also allow you to display hotel information on the offer page using Views.