nattreid/menu

Menu for Nette Framework

2.5.6 2020-04-30 06:31 UTC

README

Nastavení v config.neon

Pokud chcete využít nastavení menu přes config.neon

extensions:
    menu: NAttreid\Menu\DI\MenuExtension

menu:
    items:
        module:                                                 # hlavni modul (front, cms)
            data:                                               # namespace modulu
                link: 'Homepage:'                               # link na HP modulu
                group:                                          # skupina
                    page:                                       # presenter
                        link: action                            # link akci presenteru, nebo null pro default
                        arguments: {name: value}                # argumenty
                        toBlank: TRUE                           # otevre do noveho okna
                        count: 5                                # pocet za linkem
                        # nebo
                        count: @SomeClass::countUnapproved()    # pocet za linkem
                        # nebo
                        count: {5, info}                        # muze byt info, warning (info je default)

nebo postačí pouze zaregistrovat továrnu

services:
    - NAttreid\Menu\IMenuFactory

Použití

/** @var \NAttreid\Menu\IMenuFactory @inject */
public $menuFactory;

function createComponentMenu() {
    $menu = $this->menuFactory->create();

    $link = $menu->addLink('test', 'Test:test');
    $group = $link->addGroup('group');
    // ... atd 

    return $menu;
}

Drobečková navigace

protected function createComponentBreadcrumb() {
    $breadcrumb = $this['menu']->getBreadcrumb();
    return $breadcrumb;
}