问题
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