I am using Panelizer (4.x) and when setting any panels to a node which view mode is Panelized I get this warning when viewing the node:

Notice: Undefined index: #id in at_core_theme_suggestions_block_alter() (line 115 of themes/contrib/adaptivetheme/at_core/includes/suggestions.inc).
at_core_theme_suggestions_block_alter(Array, Array, 'block') (Line: 453)
Drupal\Core\Theme\ThemeManager->alterForTheme(Object, 'theme_suggestions', Array, Array, 'block') (Line: 462)
Drupal\Core\Theme\ThemeManager->alter(Array, Array, Array, 'block') (Line: 245)
Drupal\Core\Theme\ThemeManager->render('block', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 450)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 56)
__TwigTemplate_6bc2c2a4be03937decaa4eb1c0d39af747b44d5c7e30912d8db85c3fa5c28de6->doDisplay(Array, Array) (Line: 432)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template->display(Array) (Line: 411)
Twig_Template->render(Array) (Line: 64)
twig_render_template('core/themes/stable/templates/layout/layout--onecol.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('layout__onecol', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 92)
__TwigTemplate_593995916bb379c76ab4921d9bb62c05ef9b0a91f048a86c9efdd38d9e83a551->doDisplay(Array, Array) (Line: 432)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template->display(Array) (Line: 411)
Twig_Template->render(Array) (Line: 64)
twig_render_template('modules/contrib/panelizer/templates/panelizer-view-mode.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('panelizer_view_mode', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 576)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 108)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

It also breaks the "edit" button from the Panelizer UI JS. This Notice is shown once for each Panel on node when the mobile menu is shown.

The problem is in the line 115 which the notice suggests because if I comment the line out the mobile menu does not work at all. I can also fix the problem like this (because I know the menu #id which is mainnavigation):

// Use a custom block suggestion for responsive menus.
  if (isset($theme['path_skin'])) {
    // Skin themes need to use the base themes block elements id to match the config setting.
    $variables['elements']['#id'] = str_replace($theme['name'], $theme['base'], $variables['elements']['#id']);
  } else {
     $variables['elements']['#id'] = 'mainnavigation';
  }

Any ideas why this is happening and tips for a real patch?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TipiT created an issue. See original summary.

Jeff Burnz’s picture

Assigned: Unassigned » Jeff Burnz

Just needs a check for #id

Dylan Donkersgoed’s picture

Status: Active » Needs review
FileSize
2.33 KB

Sorry to jump in on this when it's already assigned but I found and fixed this without realizing there was already an issue. I got a series of warnings (including this one) when using page_manager. I'm attaching a patch that fixes three warnings I encountered regarding:

  • $variables['content']['#view_mode'] (in misc.inc)
  • $variables['content']['#bundle'] (also in misc.inc)
  • $variables['elements']['#id'] (in suggestions.inc)
Jeff Burnz’s picture

Assigned: Jeff Burnz » Unassigned

Sweet, I'll test this shortly. Thanks a lot!

Jeff Burnz’s picture

I can't even get this installed, I'm running drupal 8.4 and trying to install Panelizer 4.x and get issues with layout discory and layout plugin etc, what versions are you running?

John Cook’s picture

I had the same problem when trying Twitter Block. The #id element wasn't set.

The patch in #3 fixed the problem.

I haven't checked with Panelizer though. Maybe @TipiT can create reproduction instructions?

Jeff Burnz’s picture

OK, lets go with this with a few minor modifications, basically the same thing - thanks!

  • Jeff Burnz committed 82867ba on 8.x-3.x
    Issue #2934847 by Dylan Donkersgoed: block_alter function does not work...
Jeff Burnz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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