Mecha CMS

Mecha CMS blog and documentation.

Create Dynamic Menu from the Existing Pages

Updated: Sunday, 07 August 2016

How to build navigation menu automatically based on the available pages?

Automatically create navigation menu based on the available pages.

<nav class="blog-navigation">

$menus = array($speak->home => '/');
foreach(Get::pages() as $_page) {
    $_page = Get::pageAnchor($_page);
    $menus[$_page->title] = $_page->url;

Menu::add('pages', $menus);

echo Menu::pages();

Donation and Email Subscription