45 lines
1.8 KiB
PHP
45 lines
1.8 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../db/config.php';
|
|
|
|
// Fetch site title from settings
|
|
$stmt = db()->query("SELECT value FROM settings WHERE name = 'site_title'");
|
|
$site_title_setting = $stmt->fetchColumn();
|
|
$site_title = $site_title_setting ?: 'My Awesome Website';
|
|
|
|
// Fetch pages for navigation
|
|
$pages_stmt = db()->query("SELECT title, slug FROM pages WHERE is_published = 1 ORDER BY menu_order ASC");
|
|
$nav_pages = $pages_stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$current_slug = basename($_SERVER['REQUEST_URI']);
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo isset($page_title) ? htmlspecialchars($page_title) . ' | ' . htmlspecialchars($site_title) : htmlspecialchars($site_title); ?></title>
|
|
<meta name="description" content="<?php echo isset($meta_description) ? htmlspecialchars($meta_description) : 'Welcome to our website'; ?>">
|
|
<link rel="stylesheet" href="/assets/css/style.css?v=<?php echo time(); ?>">
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<div class="container">
|
|
<a href="/" class="logo"><?php echo htmlspecialchars($site_title); ?></a>
|
|
<nav>
|
|
<ul>
|
|
<li><a href="/" class="<?php echo ($current_slug == 'index.php' || $current_slug == '') ? 'active' : ''; ?>">Home</a></li>
|
|
<?php foreach ($nav_pages as $p): ?>
|
|
<li>
|
|
<a href="/page.php?slug=<?php echo htmlspecialchars($p['slug']); ?>"
|
|
class="<?php echo (isset($_GET['slug']) && $_GET['slug'] == $p['slug']) ? 'active' : ''; ?>">
|
|
<?php echo htmlspecialchars($p['title']); ?>
|
|
</a>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
</header>
|
|
<div class="container">
|
|
<main>
|