1

I have a small custom module that needs override blazy.html.twig that comes from the Blazy contributed module in Drupal 8. The code below shows what I have so far, can anyone give me some direction on how to go about this?

/**
 * Implements hook_theme().
 */

function slider_overlay_text_theme($existing, $type, $theme, $path)
{
    // In the template file I have blazy.html.twig
    $templates = $path . '/templates';

    return [
            'template' => 'blazy',
            'path' => $templates
    ];
}


/**
 * Prepares variables for blazy.html.twig templates.
 * Implements hook_preprocess_HOOK() for field templates.
 */
function slider_overlay_text_preprocess_blazy(&$variables) {

    // This variable is in the template ready to be printed
     $variables['display_hero_text'] = 'right-hero-text1';
  }
1

I found the issue to override the module template you have to call the modules name in the _theme hook $return['blazy'].

function slider_overlay_text_theme($existing, $type, $theme, $path)
{
    $templates = $path . '/templates';

    $return['blazy'] = [
        'template' => 'blazy',
        'path' => $templates
    ];
    return $return;
}
| improve this answer | |

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.