Thank you Ryan for your answer.
I found the right solution to this problem:

                $router->setGlobalParam('account', $this->_account);

This way, the "account" parameter is added to every URL built.
--
Guillaume

Le 27/12/09 03:50, ryan.horn a écrit :
Can you give an example of the URL structure you are using to access your
page, what you are passing to the url helper and what the helper is
returning? Seems to work fine for me with the route definition you provided.



Guillaume ORIOL wrote:
Working on an application that is the same for multiple customers, I had
to face a design option.
I wanted to avoid installing the application as many times as we had
customers (for maintenance reasons).
Therefore I chose to have a unique code installation but several
databases.
Each customer would access its application by adding its account name to
the application base URL:
webapp.domain.com/account1/
webapp.domain.com/account2/
etc.

Following this URL prefix are the regular MVC parameters, ie:
webapp.domain.com/account1/module/controller/action

I define a default route replacement in my Bootstrap including the
account parameter (see below) and retrieve this special parameter from a
FrontController plugin where I setup the default database adapter.

I encounter a problem with functions that build URLs (for instance
$view->url(...) or $redirector->gotoRoute(...), etc.).
All of these functions should add the current account parameter at the
beginning of the URL, but none of them is aware of it.
(It should also apply to other functions like $page->getHref() for
Zend_Navigation.)

What design option would you suggest (overload all of these functions,
change dynamically the base URL of the application)?

Thanks for any help
- - - - -
Here is the redefined default route:
          $route = new Zend_Controller_Router_Route(
              ':account/:module/:controller/:action/*',
              array(
                    'account'    =>  'demo',
                    'module'     =>  'default',
                    'controller' =>  'index',
                    'action'     =>  'index')
          );
          $router->addRoute('default', $route);

I would also like to make
"webapp.domain.com/account1/module/controller/action" equivalent to
"account1.webapp.domain.com/module/controller/action". I guess it is
possible with the Zend_Controller_Router_Route_Hostname, but did not try
already.

$route = new Zend_Controller_Router_Route_Hostname(
      ':account.webapp.domain.com',
      array(
          'module'     =>  'default',
          'controller' =>  'index',
          'action'     =>  'index'
      )
);
--

Guillaume ORIOL

Reply via email to