From c5a1c2a8c0b3348e695c19d61a24becef16480a5 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Tue, 11 Jan 2022 10:26:49 +0100 Subject: [PATCH] Add support for nested layout sections --- application/helpers/html_helper.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/application/helpers/html_helper.php b/application/helpers/html_helper.php index 9da0ee36..a58a799d 100644 --- a/application/helpers/html_helper.php +++ b/application/helpers/html_helper.php @@ -58,6 +58,7 @@ if ( ! function_exists('extend')) 'layout' => [ 'filename' => $layout, 'sections' => [], + 'tmp' => [], ] ]); } @@ -88,16 +89,23 @@ if ( ! function_exists('section')) { $layout = config('layout'); - if (array_key_exists($name, $layout['sections'])) + if (array_key_exists($name, $layout['tmp'])) { $layout['sections'][$name][] = ob_get_clean(); + unset($layout['tmp'][$name]); + config(['layout' => $layout]); return; } - $layout['sections'][$name] = []; + if (empty($layout['sections'][$name])) + { + $layout['sections'][$name] = []; + } + + $layout['tmp'][$name] = ''; config(['layout' => $layout]);