bigfishtv/magicmenu

There is no license information available for the latest version (1.1.1) of this package.

A CakePHP Plugin to generate HTML menus

Installs: 40

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:cakephp-plugin

1.1.1 2021-08-18 01:17 UTC

This package is auto-updated.

Last update: 2024-04-18 07:01:23 UTC


README

Installation

composer require bigfishtv/magicmenu

Usage

AppView.php

$this->loadHelper('MagicMenu.MagicMenu');

[your-view].[ctp|php]

$items = [
    ['title' => 'About', 'url' => '/about'],
    ['title' => 'Work', 'url' => '/work', 'children' => [
        ['title' => 'One', 'url' => '/work/one'],
        ['title' => 'Two', 'url' => '/work/two'],
        ['title' => 'Three & Four', 'url' => '/work/three-and-four'],
    ]],
    ['title' => 'Contact', 'url' => '/contact']
];
$menu = $this->MagicMenu->create($items);
echo $menu->render();

Output

<ul>
    <li>
        <a href="/about">
            <span>About</span>
        </a>
    </li>
    <li>
        <a href="/work">
            <span>Work</span>
        </a>
        <ul>
            <li>
                <a href="/work/one">
                    <span>One</span>
                </a>
            </li>
            <li>
                <a href="/work/two">
                    <span>Two</span>
                </a>
            </li>
            <li>
                <a href="/work/three-and-four">
                    <span>Three &amp; Four</span>
                </a>
            </li>
        </ul>
    </li>
    <li>
        <a href="/contact">
            <span>Contact</span>
        </a>
    </li>
</ul>