Hey,
I change the default routes, I append the region of the current locale
to each one using this code:
<?php
// Bootstrap.php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
protected function _initRouting() {
/* @var $fc Zend_Controller_Front */
$fc = $this->getPluginResource( "frontcontroller"
)->getFrontController();
/* @var $router Zend_Controller_Router_Rewrite */
$router = $fc->getRouter();
$routes =
$router->removeDefaultRoutes()->addDefaultRoutes()->getRoutes();
/* @var $locale Zend_Locale */
$locale = $this->getPluginResource( "locale" )->getLocale();
$hook = new Zend_Controller_Router_Route(
":region",
array( "region" => strtolower( $locale->getRegion() ) ),
// resources.locale.default = "es_CO"; resources.locale.force = true
array( "region" => "[a-z]{2}" )
);
foreach ( $routes as $name => $route ) {
$chain = new Zend_Controller_Router_Route_Chain();
$chain->chain( $hook )->chain( $route );
$router->addRoute( $name, $chain );
}
// set global param.
$router->setGlobalParam( "region", strtolower( $locale->getRegion() ) );
// start router resource.
$this->bootstrap( "router" );
}
}
// layouts/scripts/layout.php
echo $this->url( array( "module" => "products", "controller" =>
"index", "action" => "current-offers" ) ); // "/"
When I try to assemble a route using Zend_View_Helper_Url I get:
string(1) "/" if the url is: http://192.168.2.10:8091/ but if I append
the region: http://192.168.2.10:8091/co the helper works: string(33)
"/co/products/index/current-offers"
For 'default' module Zend Framework always remove that part from the
url, so if I have a url like this one:
blah.com/co/users/login/something it tries to match /users/ module,
there's a way to not remove /default/ string from the url?
Thanks for any help, I'm really stuck with this.
--
Juan Felipe Alvarez Saldarriaga
http://www.jfalvarez.com