Can you use a twig variable for the row custom class for carousel?

Created on 6 March 2025, 30 days ago

Problem/Motivation

Want to use a twig variable for the row custom class for carousel

Steps to reproduce

Choose Bootstrap Carousel display.
Enter a replacement pattern for the custom row class eg {{ field_colour }}
Although a class is added to carousel-inner, it has a random value <> the field result for that row.

I notice that the field makes no mention of replacement patterns.
The twig template only adds
{% set row_classes = ['carousel-item', loop.first ? 'active'] %}
so I'm not sure where the erroneous classes are added...perhaps core views theming?

I have debugged function template_preprocess_views_bootstrap_carousel and the $vars leaving there are correct....but they are wrong by the time they arrive at
views_bootstrap/templates/views-bootstrap-carousel.html.twig

Before I spend anymore time on this, I thought I'd just ask if this is even possible with the module.

πŸ’¬ Support request
Status

Active

Version

5.5

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom mchaplin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mchaplin
  • πŸ‡ΊπŸ‡ΈUnited States shelane

    Interesting question. I don't know. If you know of a views style module that does this, let me know and I'll see what they're doing for that.

  • πŸ‡¬πŸ‡§United Kingdom mchaplin

    Hi shelane

    Perhaps I should ask the question a different way.

    For the Views Bootstrap Carousel display, can you specify the custom row class with a twig variable eg {{ field_my_field_in_the_view }}....or is it only static string values eg "myclass" that would then be the same for all rows?

Production build 0.71.5 2024