I just noticed a problem with my menu. I'm working on a php application, with Zend Framework. It looks like an empty text line is inserted in my menu and I don't understand why. For example ...
As you can see, an empty space is between elements I added manually and elements generated with my menu.phtml. Here's my code ...
First, because I have 3 different menus, I saved them in Zend_Register, in my bootstrap, but I'll just show you the code for my anonymous menu.
protected function _initNavigation()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
//Init du menu anonyme
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'menuNotLogged');
$container = new Zend_Navigation($config);
Zend_Registry::set('main',$container);
$view->navigation($container);}
Then, in my layout I display my menu ...
<div id="navigation">
<ul id="primary-links">
<li id="overview"><a href="#">Overview test</a></li>
<li><a href="#">Manual test</a></li>
<?php
$partial = array('menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial);
echo $this->navigation()->menu()->render(Zend_Registry::get('main'));
?>
</ul>
</div>
Now my menu.phtml ...
foreach ($this->container as $page) {
if ($page->isVisible()) {
if ($page->isActive(true)) {
//... not active so it doesn't enter here
} else {
echo '<li>'.$this->navigation()->menu()->htmlify($page). '</li>' ;
}
}
}
I tried to debug my menu in Firebug(FF) and Developer Tools(IE8), it shows empty text in the menu like that (First image is IE, second is Firefox)
There is an empty item and I can't see where it come from! I noticed it because I need to change the template of my application, and with the old menu it did the same thing, but I didn't see it, now it's really ... visible.
It really seems to be a problem when I render my menu, because if I add elements manually, there is no problem. Looking at my code, do you have any idea of what could cause that ? Does someone ever had the same problem ? Do you need other parts of my code or other details ?
Thanks already !
UPDATE
This is my menuNotLogged in my navigation.xml
<menuNotLogged>
<home>
<label>Home</label>
<uri>/index</uri>
</home>
<login>
<label>Login</label>
<uri>/index/login</uri>
</login>
</menuNotLogged>
Here is the html output as asked
<!-- NAVIGATION_BEGIN -->
<div id="ibm-navigation">
<ul id="ibm-primary-links">
<li id="ibm-overview"><a href="http://w3">Overview test</a></li>
<li><a href="http://w3">Manual test</a></li>
<li><a href="/index">Accueil</a></li><li><a href="/index/login">Authentification</a></li>
</ul></div>
The empty line is there in my Debug Output view from Zend Studio and in Firebug too. It's probably because of this line that an empty item is added, but I don't know where it come from.
overview
li and I don't want that. I guess I'll open another question if I can't make it work :P Firefox and Chrome are ok so I guess there is a way – Fanny