header.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. $content = (new \App\Settings('content'))->getAll();
  3. $headerLogo = json_decode($content['header-logo'] ?? '{}', true);
  4. $menuItems = json_decode($content['menu'] ?? '[]', true);
  5. ?>
  6. <header class="header">
  7. <div class="container">
  8. <!-- Logo -->
  9. <div class="header__logo">
  10. <?php if (!empty($headerLogo['src'])): ?>
  11. <a href="<?= $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] ?>" class="header__logo-link">
  12. <img src="<?= htmlspecialchars($headerLogo['src']) ?>" alt="<?= $headerLogo['alt'] ?? '' ?>" title="<?= $headerLogo['title'] ?? '' ?>">
  13. </a>
  14. <?php endif; ?>
  15. </div>
  16. <!-- Navigation -->
  17. <?php if (!empty($menuItems[0]['title'])): ?>
  18. <nav class="header__nav">
  19. <ul class="header__menu">
  20. <?php foreach ($menuItems as $menuItem): ?>
  21. <li class="header__menu-item">
  22. <a href="<?= htmlspecialchars($menuItem['anchor'] ?? '') ?>" class="header__menu-link">
  23. <?= htmlspecialchars($menuItem['title'] ?? '') ?>
  24. </a>
  25. </li>
  26. <?php endforeach; ?>
  27. </ul>
  28. </nav>
  29. <?php endif; ?>
  30. <!-- Buttons -->
  31. <div class="header__actions">
  32. <?php if (empty($content['hide-btns'])): ?>
  33. <button class="header__btn header__btn--primary redirect-js">
  34. <?= htmlspecialchars($content['header_btn_1'] ?? 'Button 1') ?>
  35. </button>
  36. <button class="header__btn header__btn--secondary redirect-js">
  37. <?= htmlspecialchars($content['header_btn_2'] ?? 'Button 2') ?>
  38. </button>
  39. <?php endif; ?>
  40. <!-- Burger Menu -->
  41. <button class="header__burger" aria-label="Toggle menu">
  42. <span class="header__burger-line"></span>
  43. <span class="header__burger-line"></span>
  44. <span class="header__burger-line"></span>
  45. </button>
  46. </div>
  47. </div>
  48. </header>