Option to configure header for the caption title

Created on 29 September 2023, 9 months ago
Updated 5 October 2023, 9 months ago

I just updated to the latest 1.0.x-dev. I have a view with a splide. The page has the normal h1 header, then the view has its own h2 header, so I need the splide titles to be h3. I was previously hacking the splide-slide.html.twig file and changing the "h2" to "h3", but that doesn't seem to work anymore... it would be great if there was a UI option to choose what header to use for caption titles, etc.

✨ Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

🇺🇸United States W01F

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

Comments & Activities

  • Issue created by @W01F
  • 🇮🇩Indonesia gausarts

    Thank you.

    Make sense.

    Moving this to Blazy:2.x, since splide:3.x also works with blazy:2.x.
    I may not be able to provide the UI option for now, but will provide an alterable H2 tag via the provided hook_alters.

  • 🇮🇩Indonesia gausarts
  • Status changed to Fixed 9 months ago
  • 🇮🇩Indonesia gausarts

    We got a new 2.19 hotfix release this weekend. This will do for now.

    Updated blazy.api.php with the related changes:
    https://git.drupalcode.org/project/blazy/-/blob/8.x-2.x/blazy.api.php?re...

      // Changed default caption title tag from H2 to H3.
      $blazies->set('item.title_tag', 'h3');
    

    Thanks for easy to implement and quality feature suggestion :)

  • 🇺🇸United States W01F

    Fantastic! Thanks as always Gaus =)

  • 🇺🇸United States W01F

    Hi Gaus, still trying to figure out how use the recent updates to change the H2 > H3. I'm also seeing the following description still in the hover description for the title field in the splide options (screenshot attached).

  • 🇮🇩Indonesia gausarts

    Updated it accordingly.

    Thanks for the catch :)

  • 🇺🇸United States W01F

    Still doing something wrong - can't get these h2 headers to change to h3. Perhaps I'm just not drinking enough coffee... Any guidance/suggestions would be great.

    Seasonal recommendations has the splide slider on the homepage here:
    https://www.dev.kobejet.com/en
    Also attaching screenshot.

  • 🇮🇩Indonesia gausarts

    There are new options at Blazy UI.

    Some new features require you enabling "Use theme_blazy()" option, including your OP.

    And you need to implement hook_blazy_item_alter() in your custom module. The exact line is in #5.

    Let me know?

  • 🇺🇸United States W01F

    Yup, "Use theme_blazy()" was already enabled. And I can see the original code in the blazy module in blazy.api.php file:
    // Changed default caption title tag from H2 to H3.
    $blazies->set('item.title_tag', 'h3');

    I added this to a custom module as well:
    function hook_blazy_item_alter(array &$settings, array &$attributes, array &$item_attributes) {
    // Changed default caption title tag from H2 to H3.
    $blazies->set('item.title_tag', 'h3');
    }

    Then cleared caches, and the caption titles are still showing as h2 - https://www.dev.kobejet.com/en

    Not sure what I'm doing wrong.

  • 🇮🇩Indonesia gausarts

    May I know your exact function and its body?

    1. Try adding $blazies = $settings['blazies'];
    2. Change hook into your actual MODULE_NAME, e.g.:

    function MODULE_NAME_blazy_item_alter(array &$settings, array &$attributes, array &$item_attributes) {
      $blazies = $settings['blazies'];
    
      // Changed default caption title tag from H2 to H3.
      $blazies->set('item.title_tag', 'h3');
    }
    
  • 🇺🇸United States W01F

    Yup, was just being dumb - I hadn't changed the module name. And I did need the $blazies definition as well so thank you for that. Seems to be working now. Thanks Gaus!!

  • 🇮🇩Indonesia gausarts

    Thanks for the follow up. We'd been there, no worries. Glad you did it :)

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024