Adjust theme suggestion alter in starterkit

Created on 19 September 2022, over 2 years ago
Updated 11 February 2024, 10 months ago

Problem/Motivation

I am setting up a custom theme on a new project (CATSA) based on the starterkit provided in wxt_bootstrap. There is a hook provided in the starterkit for theme suggestions which doesn't work and should be removed (I replaced THEMENAME with my custom theme name "catsa"):

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function catsa_theme_suggestions_block_alter(&$suggestions, $variables) {

  // Load theme suggestions for blocks from parent theme.
  foreach ($suggestions as &$suggestion) {
    $suggestion = str_replace('catsa_', 'wxt_bootstrap_', $suggestion);
  }
}

With the above code in place, here is an example of the theme output for the Search Form Block:

 FILE NAME SUGGESTIONS:
   * block--search--gcweb--wxt-bootstrap-wxtsearchform.html.twig
   * block--search--wxt-bootstrap-wxtsearchform.html.twig
   * block--wxt-bootstrap-wxtsearchform.html.twig
   x block--wxt-search-form-block.html.twig
   * block--wxt-library.html.twig
   * block.html.twig

If I remove this theme suggestion alter from my custom theme I get the following:

FILE NAME SUGGESTIONS:
   x block--search--gcweb--catsa-wxtsearchform.html.twig
   * block--search--catsa-wxtsearchform.html.twig
   * block--catsa-wxtsearchform.html.twig
   * block--wxt-search-form-block.html.twig
   * block--wxt-library.html.twig
   * block.html.twig

This aligns with the name of the block template files in the starterkit. All I have to do now is rename the block template files by replaceing THEMENAME with my theme's name and all works fine.

Steps to reproduce

Fresh install of WxT, copy starterkit in wxt_bootstrap to /html/themes/custom/THEMENAME, set new theme to default and rename the block template files by replacing THEMENAME with your theme name. See the block templates are not taken into account.

Proposed resolution

Remove the hook_theme_suggestions_HOOK_alter() from starterkit.

🐛 Bug report
Status

Fixed

Version

4.3

Component

WxT Bootstrap

Created by

🇨🇦Canada smulvih2 Canada 🍁

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024