Notice: Undefined index: elements in block_theme_suggestions_block()

Created on 17 January 2022, almost 3 years ago
Updated 18 September 2024, 2 months ago

Problem/Motivation

I'm using twig_tweak to include privacy block in my custom template

{{ drupal_block('iubenda_integration_privacy_policy', wrapper=false) }}

and I get this notice message

Notice: Undefined index: elements in block_theme_suggestions_block() (line 200 of core/modules/block/block.module).
block_theme_suggestions_block(Array)
call_user_func_array('block_theme_suggestions_block', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('theme_suggestions_block', Array) (Line: 230)
Drupal\Core\Theme\ThemeManager->render('block__iubenda_privacy_policy', Array) (Line: 436)

Steps to reproduce

  1. Install and configure iubenda_integration
  2. Add {{ drupal_block('iubenda_integration_privacy_policy', wrapper=false) }} in your existing custom template

Proposed resolution

Add this 'template' => 'block--iubenda-privacy-policy', in iubenda_integration_theme() hook

as follow

/**
 * Implements hook_theme().
 */
function iubenda_integration_theme($existing, $type, $theme, $path) {
  return [
    'block__iubenda_privacy_policy' => [
      'variables' => [
        'pre_text' => NULL,
        'link' => NULL,
        'post_text' => NULL,
      ],
      'template' => 'block--iubenda-privacy-policy',
    ]
  ];
}
🐛 Bug report
Status

Postponed

Version

4.0

Component

Code

Created by

🇮🇹Italy robertoperuzzo 🇮🇹 Tezze sul Brenta, VI

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

Merge Requests

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