1

My page content type has two entity reference types that reference other content types.

  • Hero
  • Quotes

The hero displays at the top of the page and I want the Quotes at the bottom of the page.

In between these two pieces of content I have custom blocks and views that I wanted displayed. How can I have the Hero and the Quotes nodes below other custom content?

6

Using Template files

You can create a template file .html.twig for your content type or specific node.

Download and enable Twig tweak module:

Twig Tweak module provides a Twig extension with some useful functions and filters that can improve developer experience.

And then on your twig template put:

{{ content.field_refhero }}
<dd>{{ drupal_view('view_name', 'block_1') }}</dd>
<dd>{{ drupal_block('block_id') }}</dd>
{{ content.field_refquotes }}

Alternatively, you could use the following modules

Display Suite

Display Suite allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your nodes, views, comments, user data etc. the way you want without having to work your way through dozens of template files.

Panels

The Panels module allows a site administrator to create customized layouts for multiple uses. At its core it is a drag and drop content manager that lets you visually design a layout and place content within that layout. Integration with other systems allows you to create nodes that use this, landing pages that use this, and even override system pages such as taxonomy and the node page so that you can customize the layout of your site with very fine grained permissions.

2

The content is itself a block in Drupal 8.

You should be able to achieve what you want by creating a view to display the second entity reference.

In your content type, change the display settings so the Quotes field is not visible.

Now create a new Block view. Set it to display the Quotes field, and under Advanced add a Contextual Filter for the Node ID, and select a default value of Content ID from URL.

Now you can display this block below your other blocks, and it will display the quotes for the current node.

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.