So I wrote a class as such:
class Users_Navigation_Page_Notification extends Zend_Navigation_Page_Mvc{
public function setLabel($label){
if(substr($label, 0 , 1) == ':'){
$label = 'Notification';
}
return parent::setLabel($label);
}
}
And if I try something like:
$label = 'Notification' . '<span>test</span>';
It echo's out Notificationtest
which it shouldn't.
How do I make it render HTML elements out?
Answer here https://stackoverflow.com/a/32823280/3684315 suggests using
escapeLabels(false)
function to disable escaping, which seems like a nicer solution.<?= $this->navigation()->menu()->escapeLabels(false) ?>
When rendering navigations, the view helper is hardcoded to escape the label of each navigation page which by default uses
htmlspecialchars
. This would effectively disable HTML since the tags are replaced with HTML entities.You can try to cheat a bit and change the escaping mechanism prior to outputting your navigation:
In the above code, you can change
$view
to$this
if you are within a view script.