Score:-1

Show two content types in same view

rs flag

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.

No Sssweat avatar
ua flag
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".
Pierre.Vriens avatar
gb flag
I’d do exactly the same as @NoSssweat ... hey there, bonjour !!!
John avatar
rs flag
Thanks a lot guys! exactly how I did it
Score:1
us flag

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.

John avatar
rs flag
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
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.