0

I have some experience with Drupal 7, but not that much. Now I'm working on my first Drupal 8 website and stumbled over the following situation:

In a first iteration, the website should use the default theme and should be as drupal-ish as possible in its solutions. One requirement is, that I have a list of 5 "sponsor logos" that should appear on the frontpage and the imprint. They should all appear in the same height and in one row (on a desktop browser and probably break on mobile).

Due to the fact that they should appear on different pages, I guess, I want to create a block for this. But what would be the most Drupal way, to add this row of logos to this block?

Just adding pictures in the editor feels a bit "undrupalish" and it seems to be meant for only one image. Adding code by hand and adding the addresses of the images feels a bit like "Why am I actually using a CMS?"

I hope my question is precise enough to get some input.

  • Proper way IMO is a “Sponsor” Entity (or content type, I suppose) with the Fields you need, them create as many Sponsors as you need. Then use Views to create a Block display and select all published Sponsor content and output it as needed. Then place the block in the desired region. – Kevin Dec 30 '18 at 16:57
  • Thanks for the suggestion! A full content type for just one image seems a bit strange to me. Is this a "normal drupal way"? And creating the block via views, how can I configure the layout to put the five images in one row? – Byom Buttler Dec 31 '18 at 2:23
  • Because later you may want to expand on sponsors and add more structured data around them. Just a thought. – Kevin Dec 31 '18 at 3:42
  • @Kevin, your answer as actually the best, but I can't mark is as answer, because it's just a comment. Formatting things to a row with 5 columns was really straight forward as an option of the view itsef. – Byom Buttler Jan 2 at 15:22
1

A proper way IMO is a “Sponsor” Entity content type with the Fields you need, then create as many Sponsors as you need. Then use Views to create a Block display and select all published Sponsor content and output it as needed. Then place the block in the desired region. Later you may want to expand on sponsors and add more structured data around them, which is why you'd have a content type (or custom entity type) over just a single-use block type.

0

You could create a custom block type with an image field and its cardinality would be 5, in this way you can:

  • Require the 5 images to be mandatory
  • Use image styles to optimize the images
  • Use responsive images to optimize for mobile
  • Use a twig template to avoid errors in the markup and streamline the deployment of adjustments in the future (via code push).
  • Thank you for your answer! In a first try, I created a custom block type with 5 images max, created a block with the five desired images and used just a standard image type. By default, this stacks 5 divs on each other. As far as I understood responsive image styles, they just let the browser download different versions of the image for different device sizes, but otherwise doesn't change the appearance. So the question now is: How do I put these 5 logos in a row instead of stacking them? – Byom Buttler Dec 31 '18 at 2:21
  • You should be able to use CSS. If you want full control over the HTML, you could try and implement your own custom twig template, it would be something like this: drupal.stackexchange.com/questions/251859/… – Cesar Moore Jan 5 at 13:45

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.