1

I have a content type "reservation" and another "room" this is a simple booking app that Im making from stracht "just for learning purposes"

Im using entity reference for make the reservations, so I can create a new reservation and reference the room it belongs to.

So I need to create a view into a block that displays all the reservetions for the current room.

So how to make that in views? display all the entities that are referencing a certain entity.

1

You create a View that lists all reservations and then add entity_reference_field as the context.

If you use Panels, you should create a content pane and require a node id as context.

If you don't use panels, you should create a block and provide a default value to the context being the node id from the url. (When you insert the block on the node page, views will grab the node id from the url and use it in the query to display only reservations for that room).

  • Great thank you, I have added a contextual filter "entity_reference_field" and provided a default value "Content ID from URL" and works like a charm!, no relationships were needed... – SsouLlesS Jul 10 '14 at 3:47
0

Create a view of room and add a relationship of Entity Reference: Referencing entity, then you will get the referencing entity data.

  • Look the content type "reservation" has an entity reference field for "rooms" I need to display the "reservations" for a specific room so I need to get all the reservations that are referencing a certain room, why you say make a view of room? – SsouLlesS Jul 9 '14 at 14:58
  • 1
    I might have misunderstood your question, anyways you can do it either way, create view of room and add relationship to referencing entity OR create view of reservation and add relationship to referenced entity. – wolverine Jul 9 '14 at 15:27

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.