1

I currently have 2 different content types which are very different from each other. I have also created multiple content using these content types.

I want to create a view which shows only 2 specific contents one below the other. Is this possible? Currently I can only have a view which filters on the two content types but that results in all of the different instances of the content types coming onto the page and not just the ones I want.

The content that I want to show in the view have no relationship with each other, I just want to be able to filter them in using their names.

2
  • 1
    On what decision are you viewing them together? Does an admin choose it, has it to be random? Is is an article about 'ducks' and a blog about food for ducks? Always the same? How flexible has it to be?
    – MatthijsG
    May 18, 2017 at 19:59
  • The admin creates the view and chooses. It's not random, these are 2 content which are going be the same always. The flexibility I want is to be able to create more such views where I can possibly choose content 1 and content 3 instead of content 2.
    – Vishal Rao
    May 19, 2017 at 14:08

2 Answers 2

1

"2 specific contents" .. if it's very specific / admin decides, add an extra field with code. Fill 2 nodes with something like 'promo' or '1234 Hide this field in the display, so you only see the code when you're editing. In the view, filter on this field (only nodes with this and this code) and voilá.

-edit: in this way you can re-use the view for different codes. Maybe use the URL (like foobar.com/promo shows the 2 nodes with promo in the code field). Tbh, i don't know how to use the URL in Views ;-)

2
  • So this method has the drawback that I need to add extra fields to these content types that I don't really need anywhere. Also if I want to create a new view with content 1 and some other content I'd have to create more such fields.
    – Vishal Rao
    May 19, 2017 at 13:52
  • sorry I didn't completely understand what you'd explained, filtering based on a field seems to be the perfect approach considering I can set the filter to the field and use the 'equal to' operator to make sure the field is the exact one for the content I need. Combining this with OR worked beautifully. Thank you!
    – Vishal Rao
    May 19, 2017 at 14:23
0

I think you're looking for the group functionality:

  1. Under the fields section, click add.
  2. Search for "Content type", check the box, and click "Add and configure fields"
  3. If you don't want each of your rows displaying the which content type they belong to, check "Exclude from display" on the field configure popup:enter image description here
  4. Go to the Format Settings: enter image description here
  5. Under "Grouping field Nr.1", select "Content: Content Type" enter image description here
  6. Click Apply

This groups all of the rows with the same value to "Content Type". Above each group will be a header with the value of that Content Type. For example, there'll be a header "Basic Page" and below will be listed all of the basic pages.

If you want don't to display the header, you'll have to either override the template (recommended, but harder) or hide it using CSS (less recommended, but easier).

1
  • I'm using drupal 8, not sure what you mean by exclude it from display. Should I filter it out? I'm currently using the filter to include the content types.
    – Vishal Rao
    May 19, 2017 at 13:50

Your Answer

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

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