2009年3月24日星期二

Re: [fw-mvc] Modules and Routing

I've changed my Routing a bit and now it works.

Now I want to know if this is a proper way to route my application or if I
can realize this another way.

In my Initializer.php I'm initializing the routes:

...
$path = str_replace(dirname($_SERVER['PHP_SELF']), '',
$this->_request->getRequestUri());
$params = explode('/', $path);

if (preg_match('/' . $this->_config->route->extension . '$/', $path) ||
preg_match('/' . $this->_config->route->extension . '\?+.*$/', $path))
{
switch (count($params)-1)
{
case 1:
$route = new Zend_Controller_Router_Route(':pageName', $defaults);
$router->addRoute('route', $route);
break;
case 2:
$route = new Zend_Controller_Router_Route(':lang/:pageName',
$defaults);
$router->addRoute('route', $route);
break;
case 3:
$route = new Zend_Controller_Router_Route(':module/:lang/:pageName',
$defaults);
$router->addRoute('route', $route);
break;
case 4:
$route = new
Zend_Controller_Router_Route(':module/:controller/:lang/:pageName',
$defaults);
$router->addRoute('route', $route);
break;
case 5:
$route = new
Zend_Controller_Router_Route(':module/:controller/:action/:lang/:pageName',
$defaults);
$router->addRoute('route', $route);
break;
}
}
...

so I have URLs like this:
http://host/page1.html
http://host/en/page1.html
...

And if the URL doesn't end with the extension (.html or
.html?getParam=paramValue) I'm using the dafault route from Zend Framework.
--
View this message in context: http://www.nabble.com/Modules-and-Routing-tp22574143p22676227.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: