ZF2 custom attributes in navigation

后端 未结 3 1926
渐次进展
渐次进展 2021-02-04 14:09

How would I add custom attributes into Zend Framework 2 navigation?
I know I can add id or class -> but that\'s about it....

1) How would I add data-test=\'bla

3条回答
  •  我寻月下人不归
    2021-02-04 14:40

    In addition to jmbertucci comment

    Problem

    exсess caret tag in label which cause problem with:

    • breadcrumbs
    • menu translation

    Splution

    To prevent adding tag caret to label you can add support of this parameter at menu config. You should

    Go to

    src\Application\View\Helper\NewMenu.php
    

    protected function renderNormalMenu()

    /// add 4th parameter $page->get('caret')
    $html .= $myIndent . '    ' . PHP_EOL .
    $myIndent . '        ' .
    $this->htmlify($page, $escapeLabels, $addClassToListItem, $page->get('caret')) . PHP_EOL;
    

    public function htmlify()

    } else {
        $html .= $label;
    }
    //// add this if
    if($caret === true){
        $html .= '';
    }
    
    $html .= '';
    

    Now you can use it:

     array(
                    'label' => 'Some label',
                    'caret' => true,
                    'route' => 'someroute',
                    'wrapClass' => 'dropdown',
                    'class' => 'dropdown-toggle',
    

    ps . jmbertucci, you are the Man.

提交回复
热议问题