Navigation Generator

Recursively generated multi-level menu

This is a portable navigation menu generator that I made for fun.

It's a single class that takes an array or object and formats it according to a parent-child system, then runs a recursive method to generate a multi-level menu.

Demo

Source


At the bottom there is an example where it includes a parent-child system and a sorting system allowing you to arrange the items when executing the SQL query.

The table shown is from my News CMS where I use an updated version:

Source

The updated version is modified to apply bootstrap classes to the output html as to create a dropdown style menu, whereas the original just outputs a plain unordered list.

Sandbox
Sorting in the query.

Sorting in the query.

Table showing all the columns needed.

Table showing all the columns needed.