zendframework / zend-navigation

Navigation component from Zend Framework
BSD 3-Clause "New" or "Revised" License
20 stars 25 forks source link

Trouble with multiple navigations in ZF3 #68

Closed rustedwolf closed 6 years ago

rustedwolf commented 6 years ago

I've created navigation in the configuration file, according to example in Quick Star documentation. It worked with single menu, but once I've tried multiple menu approach I receive the following error:

Fatal error: Uncaught Zend\ServiceManager\Exception\ServiceNotFoundException: Unable to resolve service "ZendNavigationDefault" to a factory; are you certain you provided it during configuration?

The way I call the methof {% for page in navigation('Zend\Navigation\Default').container %} <a href="{{ url(page.route) }}" class="navbar-item">{{ page.label }}</a> {% endfor %}

froschdesign commented 6 years ago

@rustedwolf If you look at the error message, you will see that slashes are missing:

"ZendNavigationDefault"

Add extra slashes:

{% for page in navigation('Zend\\Navigation\\Default').container %} … {% endfor %}

The double backslashes are only needed in a Twig template!

rustedwolf commented 6 years ago

Thanks! That helped!