You are not logged in.
hello everyone,
how would you handle navigation when you have a multiple language site?
e.g.:
Would the
$uri = $this->_request->_getPathInfo()
approach fail?
Or would you consider only the
/index/index/
part of the URI for looking up the entry in navigation.xml?
Thanks, Udo
Offline
I would think of using routes
e.g.
/:lang/:controller/:action
Offline
Hi john.
Can this zend_navigation have a multiple container?
Example I have multiple section in XML
<configdata>
<nav1>
....
</nav1>
<nav2>
....
</nav2>
</configdata>
How to render it in phtml
Last edited by akongz (2010-03-18 08:23:13)
Offline
Hi Akongz.
I remember having issues with multiple navigation blocks in the last project I did using Zend_Navigation, and resigning myself to creating one master navigation with two root nodes inside a <pages> declaration. I know you can also write your own viewscript that will render the Navigation object and its respective Page instances based on your own business rules. A custom Zend_Navigation viewscript is probably what you're looking for.
Hope that helps!
jon
Offline
Quick question: I noticed that this doesn't set multiple 'active' states. For instance, I click on the Pages controller and in my menu it becomes the active class. Then what I want to do is click on Pages/Edit and have it add the active class to both Pages and Edit. Any ideas on how that would work?
Offline
you could go through the navigation structure and find the active link, then recursively pick up all the page names until you hit the top parent and store that in an array. Then when you print out the navigation add a check for in_array() which adds the active state.
Offline
Hi Akongz.
I remember having issues with multiple navigation blocks in the last project I did using Zend_Navigation, and resigning myself to creating one master navigation with two root nodes inside a <pages> declaration. I know you can also write your own viewscript that will render the Navigation object and its respective Page instances based on your own business rules. A custom Zend_Navigation viewscript is probably what you're looking for.Hope that helps!
jon
Thanks Jon for your all responds, I hope not bored with my questions ![]()
My issue already haved solved with this view helper
http://framework.zend.com/manual/en/zen … ation.menu
So I just write all my navigation A, navigation B or else in one section <nav>. And where I want rendered navigation A, I just type this:
<?php
$navA = $this->navigation()->findOneByLabel('Navigation A');
$options = array(
'indent' => 16,
'ulClass' => 'navigation-a'
);
echo $this->navigation()
->menu()
->renderMenu($navA , $options);
?>
Last edited by akongz (2010-04-05 07:22:21)
Offline
I tried this with Zend Framework 1.10.7
and I get the following message with your zip example:
Zend_Loader_PluginLoader_Exception: Plugin by name 'FindByUri' was not found in the registry; used paths: Zend_View_Helper_Navigation_: Zend/View/Helper/Navigation/ Zend_View_Helper_: Zend/View/Helper/:./views/helpers/:/Users/unifix/Sites/navtest/application/views/helpers/ in /Users/unifix/Sites/navtest/library/Zend/Loader/PluginLoader.php on line 412
I tried with Zend 1.8 the first and last version, and they all seem to produce the same issue. I'm running:
PHP Version 5.3.1
Last edited by unifix (2010-08-12 15:08:19)
Offline
So this is not related directly to the stuff you are talking about but it is about Zend_Navigation menu and this seemed like the place to post this.
I know there is a way to define a class to the top ul (setUlClass method), but is there a way to set the id of the top ul? and classes and ids for the different pages defined (not parameter, but html attributes)?
warning! OT:
Is it me or i the manual/reference guide a little short on details some times? Its quite good to giving an overview, but for example I cant find it saying anywhere that you can use xml to define the navigation.
This is just one example but I have felt the same with other things. Finding out stuff by reading blogs that cant find in the manual.
That being said it could be me just being completely retarded:P
Offline
Hi,
Great tutorial, as usual.
I have a question, can I set a class with the <li> element in the XML file ?
If I do this :
<search class="searching">
<label>Search</label>
<uri>/search/index</uri>
</search>
or
<search>
<class>searching</class>
<label>Search</label>
<uri>/search/index</uri>
</search>
the class is on the <a href=''> and not the parent <li>.
How do I do ?
Thanks.
Fabrice
Last edited by __fabrice (2010-09-19 08:14:29)
Offline
Hello,
I am looking for a best practice to render the languages menu (i would say language level menu). It means we have the menu structure like
Page 1
Page 11
Page 12
Page 2
....
and the language menu should be like eg. EN | FR. So that the user can switch the language on the every page.
Sure, we can write some custom function which will do that on a basis of http-request, but it sound a bit dirty. Is it there some approaches from Zend to solve this?
Offline
Hello there, hello Jon!
First I wanna thank you for all your efforts, teaching us zf.
This was really a good start for me me to dive into the whole stuff.
Now to the concrete thing. As I mentioned in the comments, the last day I had a very annoying debug session.
Your navigation / breadcrumb thing worked in my app and I already had created some view helpers.
I added viewhelper paths in the Application.ini:
resources.view.helperPath.ZendX_JQuery_View_Helper = APPLICATION_PATH "/../library/ZendX/JQuery/View/Helper/"
resources.view.helperPath.SZ_View_Helper = APPLICATION_PATH "/../library/SZ/View/Helper/"So everthing worked fine in the view scripts.
But from the point I needed the helpers in the layout I ran into trouble:
My view helper classes weren't found.
Odd twice: I had to add extra code into Bootstrap.php and even didn't know why. But it worked so far:
protected function _initViewHelpers()
{
$this->bootstrap('layout');
$view = $this->getResource('layout')->getView();
$view->addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper');
$view->addHelperPath('SZ/View/Helper/', 'SZ_View_Helper');
...
}Then came the day, when I wanted this stuff moving to the Application.ini.
I did'nt know about the behavior and funktionally of zf especially view/layout and so on.
This faulty code teached me to dig and learn more and more:
protected function _initNavigation()
{
$this->bootstrap('layout');
$view = $this->getResource('layout')->getView();
...
}This code led to the fact that i had several view renderers, so I had no access to the view helpers paths I defined in the Application.ini.
I had to define them a second time in the Bootstrap.php, see _initViewHelpers() above.
Jon, even though you led me run into the problem I wanna also thank you for that, because this issue encouraged me to read a lot of stuff from WeierOphinney, Rob Allen and so on.
At least I went into IRC #zftalk and got hints from Bittarman.
He pointed out the weird view render behavior I mentioned above.
The solution was pretty easy:
protected function _initNavigation()
{
$this->bootstrap('view');
$view = $this->getResource('view');
...
}This couldt be removed:
protected function _initViewHelpers()
{
$this->bootstrap('layout');
$view = $this->getResource('layout')->getView();
$view->addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper');
$view->addHelperPath('SZ/View/Helper/', 'SZ_View_Helper');
...
}And everthing works fine now.
Regards,
Sven
Offline
hi guys,
i have a little problem and i need some help
.
so first of all here is my navigation.xml, bootstrap and the way i visualise the breadcrumbs in my layout
http://pastebin.com/LNyBYYD5
and now the problem. when i am in the /controller/action i see the breadcrumbs, when i paginate articles /controller/action/page/1,2,3 i still see them, but when i click on article, my url goes /controller/action/page/1/articleId(this is int), the article loads but the breadcrumbs are gone. any idea what maybe wrong ? (and i dont want the title of the article to be in the breadcrumbs or something like that. i just want my breadcrumbs to be controller > action )
thanks
Last edited by SocialEvil (2011-10-27 11:16:51)
Offline