0

I'm very new to Drupal 8 theming and I'm trying to replicate a random website to practice.

I have a problem recreating this part though:

enter image description here

I have a block with the latest news articles and a block with most popular.

I wonder if I could put unique classes on each item in the list (of latest news), that way I can make the widths different and make the floats work.

Is there anyway to do this? If I'm doing this wrong and there's a better way, feel free to tell me!

  • Please have a look at What topics can I ask about here?. You cannot ask about Implementing a functionality or a layout seen in a site, for which just a description of the feature, a screenshot, or a site URL is provided. So update your question to include some relevant code or a screnshot of your view. – Neograph734 Apr 21 '16 at 11:44
  • @Neograph734 not asking anyone to build a code from scratch. Just wondering if it is possible and where I should look for it. – Nicolas Decroos Apr 21 '16 at 12:00
  • 1
    I'd create separate blocks and use the pagination function. Top post should have pager offset 0, show 1. And then for the 2 post block use offset 1 show 2. And for the 4 posts use offset 3, show 4. Much easier then attempting to set a class per row. – Neograph734 Apr 21 '16 at 12:05
  • 1
    For setting a class per row, have a look at drupal.stackexchange.com/questions/3059/… – Neograph734 Apr 21 '16 at 12:07
  • 1
    Well, then consider an answer like "even though it may not be a complete solution for your question, you may want to consider so and so as an alternative, or something that partially helps". – Pierre.Vriens Apr 21 '16 at 12:41
1

In order to replicate the desired behavior you can create several Views blocks and use the pager Display a specified number of items option. Then for each block change the amount and offset:

pager options

If you would do this with 3 different blocks and use offset/amounts of 0/1, 1/2 and 3/4 you should be able to stack them and have the desired result.

If you really really want to change the class per row, have a look at the great example Dynamically adding a CSS class to a view row with template.php where you can use a views preprocessor to set the right class per row.

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.