Closed (fixed)
Project:
Entity Reference Views Formatter
Version:
7.x-1.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Nov 2012 at 16:58 UTC
Updated:
13 Jan 2013 at 13:20 UTC
Comments
Comment #1
maximpodorov commentedYou should create a view which shows anything you want. Just one condition: the view must have one argument (context filter) which will receive entity ID of the entity which has entity reference field you configure to use this formatter. So the common use case is to create view with relationship which connects the entity containing entity reference field and the entity which is references by this field; you should add context filter for the former entity's ID; you should add fields like title for the latter entity.
Comment #2
funkytraffic commentedThanks, could you add a description based on a very common example?
Like: Reference from Node Type A to Node Type B. Setting up a View I would add which Context Filter exactly?
Comment #3
HorsePunchKid commentedHere's a specific example that I worked through, which might help you understand the structure.
I have a node type
songwith fields like title, duration, and key. I have another node typeset_list. Theset_listnode type has an entity reference field to nodes of typesong, naturally. I created a view calledset_list_songswhich I want to use on the set list page to render the list of songs. I added a contextual filter Content: Nid which is how the view knows which set list is being displayed. Then I added a relationship Entity Reference: Songs (note reference, not referencing) which tells the view how to pull out the songs for this set list.The last step is to add some fields to the display. Keep in mind that this view is primarily on the
set_list, so when I wanted to display the song title, duration, etc., I needed to choose that relationship on the configuration page when adding the fields. Otherwise, it would be trying to display the title, duration, etc. for the set list instead of the songs.Hope that helps!
Comment #4
maximpodorov commentedA perfect explanation!
Comment #5
funkytraffic commentedGreat, works for me too!
Only the field label should not be displayed if the field is empty?
Comment #6
maximpodorov commentedThe label showing issue is fixed. Thanks.
Comment #7
funkytraffic commentedThanks, I can confirm this is working now.