1
votes

I need help with this Drupal 7 situation:

  • I'm publishing travel agency offers using my own content type named "offer"
  • I'm storing information about hotels (descriptions, prices, photos, etc.) in taxonomy named "hotel"
  • I need to display relevant hotel info in each offer

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

2

2 Answers

1
votes

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.

1
votes

Try replacing the second line with $view = taxonomy_term_view($term); See documentation for taxonomy_term_view.