NavBar & SideBar Works... Kinda. Not Customized Yet.
This commit is contained in:
+8
-27
@@ -1,40 +1,21 @@
|
||||
<?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'],
|
||||
];
|
||||
?>
|
||||
|
||||
<?php global $menu_items, $active_profession; ?>
|
||||
<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):
|
||||
<!-- Displays Navigation Icons -->
|
||||
<?php foreach ($menu_items as $file => $info): ?>
|
||||
<?php
|
||||
$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'
|
||||
}
|
||||
$is_active = ($active_profession === $root_file_name) ? ' navbar__link--active' : '';
|
||||
?>
|
||||
<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 href="<?= htmlspecialchars($file) ?>" class="navbar__link<?= $is_active ?>">
|
||||
<img src="images/<?= htmlspecialchars($info[1]) ?>" alt="" class="navbar__icon">
|
||||
<?= htmlspecialchars($info[0]) ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
|
||||
Reference in New Issue
Block a user