Diba Carousel

This module renders content as a carousel, either as a configurable block that needs no View or custom code, or as the "DiBa carousel" format of any View. It works with or without Bootstrap: with a Bootstrap 5 theme it outputs the Bootstrap carousel and loads nothing of its own; with any other theme its standalone carousel brings a small script and stylesheet, only where it is shown. It also outputs the two carousels of the Diputació de Barcelona (DiBa) design system, maqueta v5: the product site carousel and the DiBa portal carousel.

It supports fieldable entities such as nodes, users, comments, media, and paragraph-based layouts when used in Layout Builder.

Key features

  • Two ways to build a carousel: a block-based configuration, or the "DiBa carousel" style of any View
  • Four styles: Bootstrap 5, Standalone (no Bootstrap needed), DiBa product site and DiBa portal (maqueta v5)
  • Plug and play: new carousels get the style that fits the default theme, and a View with no field chosen finds its image, title and description fields
  • No unneeded CSS or JavaScript: only the Standalone style attaches the module's assets
  • Accessible by default: no auto-cycling unless an interval is set (WCAG 2.2.2), pause on hover and focus, button indicators, labelled controls and keyboard navigation
  • Entity selection and bundle filtering, with publishing-status filtering
  • Image, title, description and link field mapping
  • Ordering (ascending, descending or random), pagination and content filtering with string or date comparison operators
  • Dynamic filter values from URL query parameters or path arguments, using [query:param] and [argument:N] tokens
  • Multiple-image strategy per entity: first, last, random, or one slide per image
  • Native image style support and responsive image style support
  • Link options per slide and per image: entity canonical link, image file link, or any link-type field
  • Compatibility with Layout Builder and paragraph-based content contexts
  • Safe text-format handling for description fields, with word-boundary truncation and an optional "See more" link
  • Optional "more link" below the carousel, indicators/controls toggle, items per slide and autoplay interval
  • Custom CSS classes for wrapper, image, row, column, title and description
  • Per-user access checks and cache contexts, so private or unpublished content is never leaked between users

Carousel styles

  • Bootstrap 5: the Bootstrap carousel, with captions over the image and several items per slide. The theme provides the CSS and JavaScript.
  • Standalone: the module's own carousel for themes without Bootstrap, with several items per slide and a pause button when it cycles. Its small library is attached only where it is shown.
  • DiBa product site: the hero carousel of the maqueta v5, with the caption on the left half of the image.
  • DiBa portal: the carousel of www.diba.cat, with a red box over the image and a "Read more" button.

New carousels use DiBa product site with DiBa Clean and its subthemes, Bootstrap 5 with Bootstrap 5, Barrio and Radix themes, and Standalone with any other theme. The style can be changed at any time.

Installation and configuration

As a block

  • Enable the module
  • Go to Administration > Structure > Block layout
  • Place a Diba carousel block in a region
  • Choose the entity type, bundles and slide fields
  • Optionally configure the image styles, filters and carousel style
  • Save the block and review the rendered output

With Views

  • Create a View (page or block display) that shows fields, with an image or media field
  • Set the format to "DiBa carousel"
  • Optionally choose the image, title and description fields (automatic by default), and whether each slide links to its entity, to a field or to nothing
  • Configure the carousel style, indicators, controls and interval; filters, sorting, pager and "more link" are the ones of the View

Paragraphs and Layout Builder

Diba Carousel can also be used in paragraph-based Layout Builder sections. When a paragraph is the current rendering context, the block will use that context automatically instead of falling back to a generic entity query. This avoids the mismatch that can occur between preview and final rendering.

Filtering by URL arguments and query parameters

The block's "Filter by field value" setting accepts two token placeholders so a single block configuration can filter content dynamically based on the current request, without any custom code:

  • [query:PARAM] is replaced with the value of the PARAM query string argument of the current request (for example [query:tag] on /page?tag=news resolves to news)
  • [argument:N] is replaced with the Nth path argument of the current URL (for example [argument:1] on /node/42/edit resolves to 42)

These tokens work with any filter operator, including the date operators (Greater, Greater or equal, Lower, Lower or equal), which also accept relative date keywords such as "today", "tomorrow" or "-1 week", automatically normalized to the format used by date fields.

Access control and caching

Every entity shown in the carousel block is checked against the current user's view access before being rendered, so unpublished or restricted content is never displayed to users without permission, while users with elevated permissions (such as "bypass node access" or user 1) still see the full content set. The block's render array varies its cache by the current user context, so a single cached carousel is never leaked between users with different access levels, including anonymous visitors. The Views style uses the access and caching of the View.

This module supports Custom Publishing Options, so you can use custom publishing states to filter carousel content.

Works with DiBa Clean

DiBa Carousel and the DiBa Clean theme are made to work together and are tested together: enable both and new carousels, as blocks or Views, use the DiBa product site style with the corporate look, spacing and controls, with no styling settings and no extra CSS or JavaScript.

Theme requirements

The Standalone style needs nothing from the theme. The Bootstrap 5 style needs a theme that loads the Bootstrap 5 carousel CSS and JavaScript, and the DiBa styles also need the styles of the DiBa maqueta v5: DiBa Clean 2.x includes everything.

Branches

  • 4.x: block and Views style; Bootstrap 5, standalone and DiBa maqueta v5 styles. Drupal 10.3, 11 and 12.
  • 3.x: block for Bootstrap 3, 4 and 5 themes, such as Drupal Bootstrap and Drupal Barrio.
Supporting organizations: 

Project information

Releases