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?
Comment | File | Size | Author |
---|---|---|---|
#3 | 2934847-3-block_alter-function-panelizer.patch | 2.33 KB | Dylan Donkersgoed |
Comments
Comment #2
Jeff Burnz CreditAttribution: Jeff Burnz commentedJust needs a check for #id
Comment #3
Dylan Donkersgoed CreditAttribution: Dylan Donkersgoed as a volunteer commentedSorry 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)Comment #4
Jeff Burnz CreditAttribution: Jeff Burnz commentedSweet, I'll test this shortly. Thanks a lot!
Comment #5
Jeff Burnz CreditAttribution: Jeff Burnz commentedI 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?
Comment #6
John Cook CreditAttribution: John Cook at Creode commentedI 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?
Comment #7
Jeff Burnz CreditAttribution: Jeff Burnz commentedOK, lets go with this with a few minor modifications, basically the same thing - thanks!
Comment #9
Jeff Burnz CreditAttribution: Jeff Burnz commented