WizdomWeb/resources/views/layouts/main.php

79 lines
2.9 KiB
PHP

<?php
use WizdomNetworks\WizeWeb\Core\View;
/**
* Main Layout (v7)
*
* This file serves as the primary layout template for rendering pages.
* It includes dynamic loading for sidebar, hero, and slider components.
* Implements improved error handling to prevent undefined variable issues.
*
* ## Features:
* - Dynamically loads the `head.php` partial with key page configurations.
* - Includes global navigation, footer, and main content structure.
* - Conditionally renders the hero, slider, and sidebar based on their configurations.
* - Uses Bootstrap's grid system to adjust layout dynamically.
* - Implements robust error handling to prevent undefined variable issues.
*
* ## Variables Passed:
* - `$title` (string) - The title of the page.
* - `$heroConfig` (array) - Configuration settings for the hero section.
* - `$sliderConfig` (array) - Configuration settings for the slider.
* - `$sidebarConfig` (array) - Configuration settings for the sidebar.
* - `$pageId` (string) - Unique identifier for the page, used for loading page-specific styles.
*/
// Ensure all optional configurations have default values to prevent errors
$title = $title ?? 'Wizdom Networks';
$pageId = $pageId ?? null;
$heroConfig = isset($heroConfig) && is_array($heroConfig) ? $heroConfig : ['enabled' => false];
$sliderConfig = isset($sliderConfig) && is_array($sliderConfig) ? $sliderConfig : ['enabled' => false];
$sidebarConfig = isset($sidebarConfig) && is_array($sidebarConfig) ? $sidebarConfig : ['enabled' => false];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php View::render('layouts/head', compact('title', 'heroConfig', 'sliderConfig', 'sidebarConfig', 'pageId')); ?>
</head>
<body>
<!-- Global Navigation Bar -->
<?php View::render('partials/navbar'); ?>
<main class="container">
<!-- Hero Section (Optional) -->
<?php if (isset($heroConfig['enabled']) && $heroConfig['enabled']) : ?>
<?php View::render('partials/hero', compact('heroConfig')); ?>
<?php endif; ?>
<!-- Slider Section (Optional) -->
<?php if (isset($sliderConfig['enabled']) && $sliderConfig['enabled']) : ?>
<?php View::render('partials/slider', compact('sliderConfig')); ?>
<?php endif; ?>
<div class="row">
<!-- Main Content Area -->
<div class="<?php echo (isset($sidebarConfig['enabled']) && $sidebarConfig['enabled']) ? 'col-md-9' : 'col-12'; ?>">
<?php echo $content ?? ''; ?>
</div>
<!-- Sidebar (Optional) -->
<?php if (isset($sidebarConfig['enabled']) && $sidebarConfig['enabled']) : ?>
<div class="col-md-3">
<?php View::render('partials/sidebar', compact('sidebarConfig')); ?>
</div>
<?php endif; ?>
</div>
</main>
<!-- Global Footer -->
<?php View::render('layouts/footer'); ?>
</body>
</html>