Problem is, I have no idea how I would go about this with my current code, I understand I need to use a recursive method but that's about it.
getter.class.php
public function NavList() { global $mysql; $mysql->query("SELECT `name`, `url`, `index`, `id` FROM `pageData` ORDER BY `id` ASC"); $nav_data = array(); while ($mysql->fetch($row)){ $nav_data[$row["name"]] = array( "url" => $row["url"], "name" => current(explode(".", $row["name"])), "index" => $row["index"], "id" => $row["id"] ); } return $nav_data; }setter.class.php
$nav_data = $this->get->NavList();public.php
<ul> <?php foreach($nav_data as $nav) { ?> <li> <a href="<?= $nav["url"]; ?>" class="<?php if(isset($_GET["p"]) && ($_GET["p"] == $nav["url"])) { echo "active"; } elseif(!isset($_GET["p"]) && (empty($_GET["p"]) && ($nav["index"] == 1))) { echo "active"; } ?>"><?= $nav["name"]; ?></a></li> <?php } ?> </ul>So, if you have some tips or some ideas on how I would create submenus I would greatly appreciate it!
Preferably without having a lot of code in the public.php file.