In Zend Framework 2 navigation how can I render HTML content in label?

╄→尐↘猪︶ㄣ 提交于 2019-12-25 08:48:30

问题


Zend navigation escapes my label content. Here is my code;

// config
'navigation' => array(
    'default' => array(
        array(
            'label' => 'Home',
            'route' => 'home',
        ),
        array(
            'label' => '<i class="fa fa-database"></i> Assets',
            'route' => 'assets',
            'pages' => array(
                array(
                    'label' => 'Browse',
                    'route' => 'assets/default',
                    'controller' => 'index',
                    'action' => 'index',
                ),
                array(
                    'label' => 'Detail',
                    'route' => 'assets/default',
                    'controller' => 'index',
                    'action' => 'host',
                ),
            ),
        ),
    ),
),

// in view script
<?php echo $this->navigation('navigation')->menu()
                                          ->setMinDepth(0)
                                          ->setMaxDepth(0)
                                          ->setUlClass('nav-side');?>

There is a solution here, but it does not work. I suspect it is probably for Zend Framework 1.


回答1:


There is a method called escapeLabels. You can set this to false.

<?php echo $this->navigation('navigation')->menu()
                                          ->setMinDepth(0)
                                          ->setMaxDepth(0)
                                          ->setUlClass('nav-side')
                                          ->escapeLabels(false);?>

I could not find this in the manual. If anyone can find (or add) a reference in the manual please add a link to help others.



来源:https://stackoverflow.com/questions/32823097/in-zend-framework-2-navigation-how-can-i-render-html-content-in-label

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!