views:

40

answers:

1

Iam trying to generate the menu and For that iam using navigation.xml (Zend Framework)

Contents of navigation.xml(file) 
<?xml version="1.0" encoding="UTF-8"?>
<config>
<nav>
<page1>
<pages>
<label>test</label>
    <uri>abc.php</uri> </pages><page1></nav></config>

and in the controller iam reading the config.xml file as follows

 $config = new Zend_Config_Xml('/configuration/navigation.xml', 'nav');
 $container = new Zend_Navigation($config);
 $view->getHelper('navigation')->setContainer($container);

In the Above XML file How do i pass the dynamic value to "abc.php?param1=".$paramvalue if Not possible from XML file How do I pass from the Controller by taking the Url from navigation.xml And that page abc.php gets activated only if the right parameter is passed if not it will be redirected to default.php

in the View iam just saying echo $this->navigation()->menu()->render(); it displays the pages as and each page needs to have a parameter appended to it in order to be transferred to appropriate location.So My problem is how to append the dynamic parameter to each link coming from navigation.xml

what iam doing is getting the page as label if the page has the value "myPage" than then iam setting the new URI with the page as expected

    $it = new RecursiveIteratorIterator(
    $container, RecursiveIteratorIterator::SELF_FIRST);

  foreach ($it as $page) {
    $label = $page->label;
    if($label = "MyPage"){
        $newuri = "mypage.php?stcode=".$stcode."&cde=".$cde;            
        $page->setUri($newuri);
    }           

}

 Now my problem and all the menu items in the menu are getting the same URI .
 i dont know what  wrong iam doing 
+1  A: 

I'm not sure what are you trying to achieve, but you may set params for MVC pages like that:

<page1>
<pages>
<label>test</label>
<params>
<param1>param1value</param1>
<myparam2>myparam2value</myparam2>
</params>

or:

<page1>
<pages>
<label>test</label>
<uri>abc.php?param1=val</uri>

Then you may find it by:

$page = $container->findOneByLabel('test');
$page->setUri($yourNewUri);

You may use RecursiveIterator to iterate all the page containers, to find the one you need and update it (eg. in controller plugin).

takeshin
@takeshin: How do i pass the "Val" as dynamic value from navigation.xml file
Someone
@Someone There is no ready method for that, you have to update whole `<uri>`
takeshin
@takeshin: You mean You are saying to update the URI in the controller.is it Correct?if Yes, How do i do that
Someone
The best way to do it is in the controller plugin. Get navigation container from the view, as in your post, find the page you need using `$container->find…`, then set the uri using `setUri()` or `$page->uri`
takeshin
@takeshin: I have updated the question .Please See and help me
Someone