0

Drupal 8 newb here,

I have two basic types I need to show in my front page: There’s a “Restaurants” content type and a “Chefs” content type.

These are shown in my site like this:

Site layout

The types are unrelated, I just need to show them in the same page as featured.

I’ve found documentation on how to make blocks and views but nothing about mixed content, which seems to me like a common use case.

Thanks in advance.

3
  • 1
    Since you want to list each type separate and not mixed, your only choice is to create two separate view blocks for each type. You could then add those view blocks to the header or footer of page view by adding a "view area".
    – No Sssweat
    Sep 12, 2021 at 1:12
  • I’d do exactly the same as @NoSssweat ... hey there, bonjour !!! Sep 12, 2021 at 15:57
  • Thanks a lot guys! exactly how I did it
    – John
    Oct 12, 2021 at 17:05

1 Answer 1

2

You don't need to use blocks: You can create a view with a page and an attachment. First from admin/structure/views/add, you create a view for content, selecting the content type to show and selecting Create a page.

screenshot

Click on Save and edit. On the next page, which shows the view settings, click on the + Add button and select Attachment.

screenshot

The next page will show the settings for the attachment.

screenshot

The attachment shows nodes for the same content type the Page view does. The first step is changing that. Click on the Content: Content type in the filtering criteria.

screenshot

On the top, change For from All displays to This attachment (override), select the content type to show. Click on Apply (this display).

The attachment still need to be attached to the Page view. On Attach to: Not defined click on Not defined.

screenshot

On the dialog box, select Page and click on Apply.

screenshot

If you want the attachment to appear after the main content, change from Attachment position: Before to Attachment position: After*. Then, click on Save to save the settings.

The view needs to be styled better (for example, selecting Grid as format instead of Unformatted list), but it shows two different content types on the same page.

1
  • Thank you very much! Did it almost the same except I created blocks instead of attachments as I had to manage lots of other fields
    – John
    Oct 20, 2021 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.