Refer to a field in another content type

Rating

If you work with a reference field (content, user, taxomomy,..) you can choose from a list of items. In the display you see the referring title, with or without link.

What if you want more than the title of the reference field? In a view it is easy. A relation makes it possible.

In the example beneath you see that i am able to show the picture of the referring painter in the node of the 'Mona Lisa'.

You can do this in 4 different ways...

Drupal8_002772.png

1) Display mode of the refence field

Set the reference field display on 'rendered entity'. Choose the mode. If the teasermode is already taken, one can make your own modes in Drupal 8.

Drupal8_002778.png

First set the teaser mode as you want.

Drupal8_002779.png

If you have a multiple field, using the Field Limiter module you can show the number of items you want. Still a sandbox prodject but it works..(https://www.drupal.org/node/1234624)

 

Drupal8_002781.png

Set as many pictures you want to show. ( I know you can do the same with colorbox or some slideshows.)



Drupal8_002780.png

2) The Token filter

With the token module one can refer to any entity you want, also fields. You can refer even to fieds in another content type using the reference field.

Drupal8_002773.png

With the token Filter module you can use these tokens in any textfield. Activate the filter in the text format (see module contribution)

Drupal8_002782.png

You can use HTML en CSS if you want, but one can not choose how many images you want to see in a multiple image field. You could solve this problem by making an extra imagefield with one image.

Drupal8_002777.png

3) A viewfield with contextual filter

Make a view from the content of the content type with the reference field. Eg Paintings referring to Painters

Drupal8_002783.png

Set up a relation. Hide the fields of the parent content type. All the painters are now visible. Therefore we us a contextual filter.

Drupal8_002784.png

The contextual filter.
Drupal8_002785.png

Now integrate the view in the content type as a field, using the viewfield module. Give the NID as argument. We did that in the contextual filter too..


Drupal8_002786.png

One can show as many images as you want using the multiple settings in the view

4) EVA field with argument

At last one can use the EVA module. The advantage is that the field only shows up in the display mode of the content type. Choose the bundle and argument. Done..

Drupal8_002787.png