I've created a new sub-theme called "evo" using the "omega_startkit" as the boilerplate code.
After adding additional regions I've noticed the {{region_classes}} array in the page.html.twig template file isn't correctly imploding the array. It's omitting a space between the different region class arrays.
Incorrect Array Implode
"branding-layout with--branding without--menusnavigation-layout with--navigationhero-layout with--herofocus-layout"
Correct Array Implode
"branding-layout with--branding without--menus navigation-layout with--navigation hero-layout with--hero focus-layout"
A solution, for anyone interested in quickly solving the problem is to alter the "omega.theme" file in the base Omega on lines 311. By omitting the (from what I can see unnecessary) ['#plain_text'] array field added to each "group_id" array.
$pass_classes[$group_id]['#plain_text'] = implode(" ", $region_classes[$group_id]);
turns into
$pass_classes[$group_id] = implode(" ", $region_classes[$group_id]);
Comment | File | Size | Author |
---|---|---|---|
#4 | omega-stop-array-classes-imploding-2690791-4-d8.patch | 629 bytes | Axel Pressbutton |
Comments
Comment #2
kamescg CreditAttribution: kamescg as a volunteer commentedComment #3
Axel Pressbutton CreditAttribution: Axel Pressbutton at Cameron and Wilding Ltd commentedHi @kamescg
It appears that this is also an issue for a clean install of Drupal 8 along with an unmodified Omega theme/subthem (in terms of additional Regions).
The following is from the default homepage of a fresh build:
<div id="page" class="clearfix header-layout with--header without--menuspreface-layout with--preface-first without--preface-second without--preface-third without--preface-fourthcore-layout with--highlightedmain-layout with--content with--sidebar-first with--sidebar-secondpostscript-layout without--postscript-first without--postscript-second without--postscript-third without--postscript-fourthfooter-layout with--footer-core-layout">
In this scenario, simply removing
['#plain_text']
results in:<div id="page" class="clearfix ">
As the output of
$pass_classes
is a multi-dimensional array with each of the arrays within it being a render array, I found that an alternate way to fix this was to keep the arrays as they were but then join them together in page.tpl.twig with the use of the safe_join option (Filters - Modifying Variables In Twig Templates)...<div id="page" class="clearfix {{ region_classes|safe_join(" ") }}">
The resulting output is then;
<div id="page" class="clearfix header-layout with--header without--menus preface-layout with--preface-first without--preface-second without--preface-third without--preface-fourth core-layout with--highlighted main-layout with--content with--sidebar-first with--sidebar-second postscript-layout without--postscript-first without--postscript-second without--postscript-third without--postscript-fourth footer-layout with--footer -core-layout">
Comment #4
Axel Pressbutton CreditAttribution: Axel Pressbutton at Cameron and Wilding Ltd commentedHere's a small patch...
Comment #5
kamescg CreditAttribution: kamescg as a volunteer commented@Axel - A much better solution :)
I went to confirm removing ['#plain_text'] created a an empty return array, and lo'an'behold you were correct. Oddly enough, this wasn't the case when I first applied the change, which I'll go ahead and blame on the cache. Still getting used to Drupal 8, but loving Twig already!
Comment #6
Axel Pressbutton CreditAttribution: Axel Pressbutton at Cameron and Wilding Ltd commentedComment #7
Axel Pressbutton CreditAttribution: Axel Pressbutton at Cameron and Wilding Ltd commentedThanks @kamescg.
Yes, really liking Twig as well!