src/View/Helper/NavbarHelper.php
public function beginMenu($name = null, $url = null, $options = [],
                              $linkOptions = [], $listOptions = []) {
        $template = 'outerMenuStart';
        $templateOptions = [];
        if (is_array($name)) {
            $options = $name;
        }
        $options += [
            'templateVars' => []
        ];
        if ($this->_level == 1) {
            $linkOptions += [
                'caret' => '<span class="caret"></span>'
            ];
            $template = 'innerMenuStart';
            $templateOptions['dropdownLink'] = $this->formatTemplate('dropdownLink', [
                'content' => $name,
                'caret' => $linkOptions['caret'],
                'url' => $url ? $this->Url->build($url) : '#',
                'attrs' => $this->templater()->formatAttributes($linkOptions, ['caret'])
            ]);
            $templateOptions['dropdownMenuStart'] = $this->formatTemplate('dropdownMenuStart', [
                'attrs' => $this->templater()->formatAttributes($listOptions)
            ]);
        }
        $this->_level += 1;
        return $this->formatTemplate($template, $templateOptions + [
            'attrs' => $this->templater()->formatAttributes($options),
            'templateVars' => $options['templateVars']
        ]);
    }
public function beginMenu($name = null, $url = null, $options = [],
                              $linkOptions = [], $listOptions = []) {
        $template = 'outerMenuStart';
        $templateOptions = [];
        if (is_array($name)) {
            $options = $name;
        }
        $options += [
            'templateVars' => []
        ];
        if ($this->_level == 1) {
            $linkOptions += [
                'caret' => '<span class="caret"></span>'
            ];
            $template = 'innerMenuStart';
            $templateOptions['dropdownLink'] = $this->formatTemplate('dropdownLink', [
                'content' => $name,
                'caret' => $linkOptions['caret'],
                'url' => $url ? $this->Url->build($url) : '#',
                'attrs' => $this->templater()->formatAttributes($linkOptions, ['caret'])
            ]);
            $templateOptions['dropdownMenuStart'] = $this->formatTemplate('dropdownMenuStart', [
                'attrs' => $this->templater()->formatAttributes($listOptions)
            ]);
        }
        $this->_level += 1;
        return $this->formatTemplate($template, $templateOptions + [
            'attrs' => $this->templater()->formatAttributes($options),
            'templateVars' => $options['templateVars']
        ]);
    }
public function beginMenu ( $ name = null , $ url = null , $ options = [ ] , $ linkOptions = [ ] , $ listOptions = [ ] ) { $ template = 'outerMenuStart' ; $ templateOptions = [ ] ; if ( is_array ( $ name ) ) { $ options = $ name ; } $ options += [ 'templateVars' => [ ] ] ; if ( $ this -> _level == 1 ) { $ linkOptions += [ 'caret' => '<span class="caret"></span>' ] ; $ template = 'innerMenuStart' ; $ templateOptions [ 'dropdownLink' ] = $ this -> formatTemplate ( 'dropdownLink' , [ 'content' => $ name , 'caret' => $ linkOptions [ 'caret' ] , 'url' => $ url ? $ this -> Url -> build ( $ url ) : '#' , 'attrs' => $ this -> templater ( ) -> formatAttributes ( $ linkOptions , [ 'caret' ] ) ] ) ; $ templateOptions [ 'dropdownMenuStart' ] = $ this -> formatTemplate ( 'dropdownMenuStart' , [ 'attrs' => $ this -> templater ( ) -> formatAttributes ( $ listOptions ) ] ) ; } $ this -> _level += 1 ; return $ this -> formatTemplate ( $ template , $ templateOptions + [ 'attrs' => $ this -> templater ( ) -> formatAttributes ( $ options ) , 'templateVars' => $ options [ 'templateVars' ] ] ) ; }
Start a new menu.

Two types of menus exist:
- Horizontal hover menu in the navbar (level 0).
- Vertical dropdown menu (level 1).
The menu level is determined automatically: A dropdown menu needs to be part of
a hover menu. In the hover menu case, pass the options array as the first argument.

You can populate the menu with `link()`, `divider()`, and sub menus.
Use `'class' => 'navbar-right'` option for flush right.

**Note:** The `$linkOptions` and `$listOptions` parameters are not used for menu
at level 0 (horizontal menu).

### Options

- `templateVars` Provide template variables for the menu template.
- Other attributes will be assigned to the menu element.

### Link Options

- `caret` HTML caret element. Default is `'<span class="caret"></span>'`.
- Other attributes will be assigned to the link element.

### List Options

- Other attributes will be assigned to the list element.

@param string $name Name of the menu.
@param string|array $url URL for the menu.
@param array $options Array of options for the wrapping element.
@param array $linkOptions Array of options for the link. See above.
@param array $listOptions Array of options for the openning `ul` elements.

@return string HTML elements to start a menu.
Start a new menu .