we have this code in template.theme but when we go to view the web, the page show a error as this: "isEven" is an invalid render array key /web/core/lib/Drupal/Core/Render/Element.php . I dont understand very good Drupal and as works it.
function fcjc_bootstrap_preprocess_paragraph(&$variables) { /** @var DrupalparagraphsEntityParagraph $paragraph */ $paragraph = $variables['paragraph']; if ($paragraph->getType() === 'image_text_full_width' || $paragraph->getType() === 'imaxe_texto_biografia_') { $variables['isEven'] = $variables['elements']['isEven']; } } function fcjc_bootstrap_preprocess_field__field_image_text_section(&$vars) { foreach ($vars['items'] as $delta => &$item) { $classname = ($delta % 2 == 0 ? 'even' : 'odd'); $item['attributes']->setAttribute('class', $classname); $item['content']['isEven'] = ($delta % 2 == 0); } }
In paragraph.twig I have this: <div class=" image col-sm-4 col-xs-12 {% if isEven %}right-shadow{% else %}left-shadow col-sm-push-8{% endif %}">
Can Somebody can help me? please. Thx