User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children() (line 98 of core/lib/Drupal/Core/Render/Element.php) with Drupal 9.3.9

Created on 17 April 2022, over 2 years ago
Updated 2 August 2024, 4 months ago

Problem/Motivation

The error 'User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children() (line 98 of core/lib/Drupal/Core/Render/Element.php)' occures when install with Drupal 9.3.9
The 'attributes' should be replaced with '#attributes' in skeletontheme_preprocess_page(&$variables) function.
The code below works for me.

function skeletontheme_preprocess_page(&$variables) {
  $sidebar_first = !empty($variables['page']['sidebar_first']);
  $sidebar_second = !empty($variables['page']['sidebar_second']);

  if ($sidebar_first) {
    $variables['page']['sidebar_first']['#attributes']['class'][] = 'five columns';
    if ($sidebar_second) {
      $variables['page']['sidebar_second']['#attributes']['class'][] = 'five columns';
      $variables['page']['content']['#attributes']['class'][] = 'six columns';
    }
    else {
      $variables['page']['content']['#attributes']['class'][] = 'eleven columns';
    }
  }
  else {
    if ($sidebar_second) {
      $variables['page']['content']['#attributes']['class'][] = 'eleven columns';
      $variables['page']['sidebar_second']['#attributes']['class'][] = 'five columns';
    }
    else {
      $variables['page']['content']['#attributes']['class'][] = 'sixteen columns';
    }
  }
}
๐Ÿ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

๐Ÿ‡ง๐Ÿ‡ฌBulgaria i.koychev Sofia

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