sidebar.php 1.1 KB

12345678910111213141516171819202122232425
  1. <?php
  2. /**
  3. * layouts/sidebar.php
  4. *
  5. * Reusable sidebar menu for dashboard pages.
  6. * Usage: include __DIR__.'/layouts/sidebar.php';
  7. */
  8. $sidebarItems = $sidebarItems ?? [
  9. [ 'href' => '/dashboard/dashboard.php', 'label' => 'Home', 'icon' => 'fas fa-home' ],
  10. [ 'href' => '/dashboard/crop-analysis/soil-analysis.php', 'label' => 'Soil Analysis', 'icon' => 'fas fa-seedling' ],
  11. [ 'href' => '/dashboard/crop-analysis/soil-report.php', 'label' => 'Soil Reports', 'icon' => 'fas fa-file-alt' ],
  12. [ 'href' => '/login/change-password.php', 'label' => 'Account', 'icon' => 'fas fa-user-cog' ],
  13. ];
  14. $activeItem = $activeItem ?? '';
  15. ?>
  16. <div class="sb-sidenav-menu">
  17. <div class="nav">
  18. <?php foreach ($sidebarItems as $item): ?>
  19. <a class="nav-link<?= ($activeItem === $item['label'] ? ' active' : '') ?>" href="<?= htmlspecialchars($item['href'], ENT_QUOTES, 'UTF-8') ?>">
  20. <div class="sb-nav-link-icon"><i class="<?= htmlspecialchars($item['icon'], ENT_QUOTES, 'UTF-8') ?>"></i></div>
  21. <?= htmlspecialchars($item['label'], ENT_QUOTES, 'UTF-8') ?>
  22. </a>
  23. <?php endforeach; ?>
  24. </div>
  25. </div>