Files
ahand/TargetScanner/nav.php
T

45 lines
1.9 KiB
PHP
Executable File

<?php
$current_file = basename($_SERVER['SCRIPT_NAME']); // Extracts File Name ONLY, Not File Path
/* Navigation Bar Pages, 'fileName' => ['Page Name', 'pageIcon'] */
$menu_items = [
'index.php' => ['Home', 'logo.png'],
'alchemyIngredientPage.php' => ['Alchemy', 'alchemy.png'],
'blacksmithing.php' => ['Blacksmithing', 'blacksmithing.png'],
'engineering.php' => ['Engineering', 'engineering.png'],
'jewelcrafting.php' => ['Jewelcrafting', 'jewelcrafting.png'],
'leatherworking.php' => ['Leatherworking', 'leatherworking.png'],
'tailoring.php' => ['Tailoring', 'tailoring.png'],
];
?>
<header class="site-header">
<button id="sidebar-toggle" class="toggle-btn" aria-label="Toggle Sidebar">
☰
</button>
<nav class="navbar" aria-label="Profession Navigation">
<ul class="navbar__list">
<!-- Finds & Sets Active Profession Page -->
<?php foreach ($menu_items as $file => $info):
$root_file_name = pathinfo($file, PATHINFO_FILENAME); // Extracts File Name ONLY, Not File Path
$is_current = (str_starts_with($current_file, $root_file_name));
$is_active = $is_current ? ' navbar__link--active' : '';
if ($is_current) {
$active_profession = $root_file_name; // File Name, e.g., 'alchemyIngredientPage' or 'blacksmithing'
$active_profession_title = $info[0]; // Page Name, e.g., 'Alchemy' or 'Blacksmithing'
}
?>
<li class="navbar__item">
<a href="<?php echo $file; ?>" class="navbar__link<?php echo $is_active ?>">
<img src="img/<?php echo $info[1]; ?>" alt="<?php echo $info[0] ?>"
class="navbar__icon">
</a>
</li>
<?php endforeach; ?>
</ul>
</nav>
</header>
<script src="sidebar.js"></script>