forked from mirrors/easyappointments
Support multiple additions of the same section content
This commit is contained in:
parent
cd2fe86aa3
commit
0a005d570b
1 changed files with 18 additions and 8 deletions
|
@ -28,19 +28,19 @@ if ( ! function_exists('component'))
|
|||
* @param string $component Component template file name.
|
||||
* @param string $attributes HTML attributes for the parent component element.
|
||||
* @param array $params Additional parameters for the component.
|
||||
* @param bool $return Whether to return the HTML or echo it directly.
|
||||
*
|
||||
* @return string Return the HTML if the $return argument is TRUE or NULL.
|
||||
* @param bool $return Whether to return the HTML or echo it directly.
|
||||
*
|
||||
* @return string Return the HTML if the $return argument is TRUE or NULL.
|
||||
*/
|
||||
function component(string $component, string $attributes = '', array $params = [], bool $return = FALSE)
|
||||
{
|
||||
/** @var EA_Controller $CI */
|
||||
$CI = get_instance();
|
||||
|
||||
|
||||
$vars = array_merge($params, [
|
||||
'attributes' => $attributes
|
||||
]);
|
||||
|
||||
|
||||
return $CI->load->view('components/' . $component, $vars, $return);
|
||||
}
|
||||
}
|
||||
|
@ -90,14 +90,14 @@ if ( ! function_exists('section'))
|
|||
|
||||
if (array_key_exists($name, $layout['sections']))
|
||||
{
|
||||
$layout['sections'][$name] = ob_get_clean();
|
||||
$layout['sections'][$name][] = ob_get_clean();
|
||||
|
||||
config(['layout' => $layout]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$layout['sections'][$name] = '';
|
||||
$layout['sections'][$name] = [];
|
||||
|
||||
config(['layout' => $layout]);
|
||||
|
||||
|
@ -116,6 +116,16 @@ if ( ! function_exists('slot'))
|
|||
{
|
||||
$layout = config('layout');
|
||||
|
||||
echo $layout['sections'][$name] ?? '';
|
||||
$section = $layout['sections'][$name] ?? NULL;
|
||||
|
||||
if ( ! $section)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($section as $content)
|
||||
{
|
||||
echo $content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue