0

I have route in bootstrap.php witch contains :

protected function _initRoutes()

{
        $router->addRoute(
            'default',
            new Zend_Controller_router_Route('/:lang/:module/:controller/:action/*',
                array('lang'=>'fa',
                        'module' => ':module',
                        'controller'=>'index',
                        'action'=>'index',
                    )
                )
        );
}

But instead of replacing module name , it returns %3module witch is url encoding of :module when i use this line :

$this->url(array('controller'=>'index','action'=>'index'),'default',true) ;

What should i do to get module name from requested URL witch is not working in _initRoutes() ?

1 Answer 1

2

Use this

$router->addRoute(
            'default',
            new Zend_Controller_router_Route('/:lang/:module/:controller/:action/*',
                array('lang'=>'fa',
                        'module' => 'default', //set the default module
                        'controller'=>'index',
                        'action'=>'index',
                    )
                )
        );

FYI: Manual

Or

Otherwise pass module name into url helper,

$module = $this->getRequest()->getModuleName();
$this->url(array('module'=>$module,'controller'=>'index','action'=>'index'),'default',true) ;
Sign up to request clarification or add additional context in comments.

1 Comment

yes , it is what my code look likes at first but i want to get it from url .the problem is, the _initRoutes function can't get url parameters to replace it,i think.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.