1

I am looking to create a view for my home page that displays the 3 last added items for 2 different content types (articles and news). Like 2 lists next to each other that also has the option to show more.

enter image description here

I already tried by creating a view with one of the 2 content types but I couldn't seem to manage to show both content types in the same view.

  • Add a filter, select Content Type, and then check off both Article and News. Sort by 'last updated', DESC. You could GROUP BY content type to split them, and set a max limit of 6 items to display. – Kevin May 14 at 13:34
  • @Kevin that can get me something like this: ibb.co/BZsB5bP ? I thought I had tried this already but will give it another shot! – lWA May 14 at 13:39
2

You can create two views, one for each content type, the configuration is the same, Filter Criteria should be Content Type (select in one articles and in the other news) you should sort by Authored on in DESC order, in the pager select Display a specified number of items (3) and More link (Yes).

Then you can add the two blocks to the page and add the styles with css.

  • I got the 2 lists made as you suggested and got to show them on the homepage. Now I would like to create some custom css to style them. Already got a custom class on each of the columns but I just don't know where to put the css files... – lWA May 14 at 19:35
  • @iwa in this case search on google how to add css styles in drupal 8 – Adrian Cid Almaguer May 14 at 20:42
0

If you want two lists, then I'll double Adrian's answer, and say you're going to want two different views. If you select both content types in the same feed, then they'll be interspersed, an order like this: article1 news1 article2

You can add the links by modifying the twig template in your theme.

  • What Adrian suggested was exactly what I needed. Can't make my upvote shown yet but this was also a good answer! – lWA May 14 at 19:36
  • maybe you can answer the question I commented there? – lWA May 14 at 19:46

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.