Search code examples
zend-frameworkzend-navigation

Url problem: zend navigation appends routes to url - How to modify zend navigation default rendering


I have reedited the question to show where was the problem.

Hi, I'm building an cms application with Zend Framework. Everything works fine except for the >urls. When I click on a link that points to:

'dep/open/id/001' 

I effectively get there but the link text is appended to the url. If I now hover on >another link I can see in the status bar:

'dep/open/id/dep/open/id/023'

and so on.

I can't edit the urls because it's Zend_Navigation which is rendering them.

How can I modify this?

Thanks

The problem was that I was giving Zend_Navigation wrong uris:

public function renderAction()
{
    ...

        //THIS IS WRONG:
        $uri =  'dep/show/id/' . $dep->dept_id;
        ...

        $itemArray[] = array(
                    'label' =>$label,
                   'uri' => $uri
                   );
    }
    $container = new Zend_Navigation($itemArray);
        $this->view->navigation()->setContainer($container);
}

The uri should be :

 $uri = $dep->dept_id;

I think this may be because I have set a route for 'dep'

$route = new Zend_Controller_Router_Route(
        'dep/show/:id',
        array(
            'action' => 'show',
            'controller' => 'dep',
            'module' => 'default',
            'id' => '',
            ),
        array( 
            'id' => '[0-9]+'
            )
        ); 

        $router->addRoute('dep', $route);

Could that be the reason?

Thanks again


Solution

  • After the first reedition of the question I have continued experimenting with the routes and the parameters passed to Zend_Navigation and I have come to the coclusion that actually the problem was that I had already set the 'dep' route to:

    '/dep/show/id' 
    

    so passing the same route in the $uri parameter to Zend_Navigation produced the duplication problem.

    It seems that I don't find solutions until I post questions here Thank you all for your patience