I have done something like that based on MJS_Controller.
http://framework.zend.com/wiki/display/ZFUSER/MJS_Controller_PathRouter+-+An+enhanced+RewriteRouter

I just modified MJS_Controller_Router_PathRoute to be able to use
resolved var in appending/prepending routing option.

this is my 2 routes

next route will match kind of url
- /infos/faq/      section=>infos, ctrl=>Faq/faq, action=>Index ,
render=>html
- /html/infos/faq/      section=>infos, ctrl=>Faq/faq, action=>Index ,
render=>html
- /adm/infos/faq/list   //  /html/infos/faq/      section=>infos,
ctrl=>Faq/faq, action=>list , render=>adm
- /jeux/loto/result   section=>infos, ctrl=>Jeux/Loto, action=>Result ,
render=>html

// Route merchand
$router->addRoute('fdj',
  new MJS_Controller_Router_PathRoute(
      '/:render:section/:controller/:action/',
      array(
          'action'        => 'index',
          'controller'    => 'index',
          '+controller'    => ':section/',            // this is
exactly what you ask for
          'render'        => 'html/',
          )
      ,
      array(
          'render'    => '(?:html/|adm/|rss/|fdjml/)?',
          'section'    => 'infos|jeux',
      )
  )
);

Next route is little bit smarter, because it have to manage a deeper
path with 2 chained controller
First level controller have generique action to forward on next
controller/action, so action1 and controller2 are always same name
next route will match kind of url
- /corp/cyclisme/boutique/detail                       lang=>fr,
controller1=>Corp/Cyclisme/Cyclisme action1=>boutique,
controller2=>Corp/Cyclisme/Boutique, action2=>detail, render=>html
- /corp/cyclisme/boutique/presentation             lang=>fr,
controller1=>Corp/Cyclisme/Cyclisme action1=>boutique,
controller2=>Corp/Cyclisme/Boutique, action2=>presentation, render=>html
- /corp_uk/cyclisme/boutique/presentation       lang=>uk,
controller1=>Corp/Cyclisme/Cyclisme action1=>boutique,
controller2=>Corp/Cyclisme/Boutique, action2=>presentation, render=>html
- /rss/corp_uk/cyclisme/boutique/presentation  lang=>uk,
controller1=>Corp/Cyclisme/Cyclisme action1=>boutique,
controller2=>Corp/Cyclisme/Boutique, action2=>presentation, render=>rss
- /corp/cyclisme/devenir/contact                      lang=>fr,
controller1=>Corp/Cyclisme/Cyclisme action1=>devenir,
controller2=>Corp/Cyclisme/Devenir, action2=>contact, render=>html
- /corp/detaillant/devenir/contact                      lang=>fr,
controller1=>Corp/Detaillant/Detaillant action1=>devenir,
controller2=>Corp/Detaillant/Devenir, action2=>contact, render=>html

// Route corporate
$router->addRoute('fdjcorp-render',
  new MJS_Controller_Router_PathRoute(
      '/{:render}corp:lang/:controller/:action/:action2',
      array(
          'lang'        => 'fr',
          '+controller' => 'Corp/{:controller}/',            // will
search controller in subdir '/Corp/ControllerName/'
          'controller' => 'Index',
          'action'    =>    'index',
          'action2'    =>    'index',
          'render'        => 'html/',
          )
      ,
      array(
          'render'    => '(?:html/|adm/|rss/|fdjml/)?',
          'lang'    => '_(?:fr|uk)',
      )
  )
);

here it is the tree directory of controllers ( as you can see, this
allow me to have many second controller with same name

/c/Info/FaqController.php
/c/Info/NewsController.php
/c/Info/IndexController.php
/c/Info/...
/c/Jeux/LotoController.php
/c/Jeux/KenoController.php
/c/Jeux/...
/c/Corp/Cyclisme/CyclismeController.php   // Generique forward controller
/c/Corp/Cyclisme/BoutiqueController.php
/c/Corp/Cyclisme/DevenirController.php
/c/Corp/Cyclisme/...
/c/Corp/Detaillant/DetaillantController.php   // Generique forward
controller
/c/Corp/Detaillant/DevenirController.php
/c/Corp/Detaillant/ContactController.php
/c/Corp/Detaillant/...
/c/Corp/...

Peter Pistorius a écrit :
> Hello everyone,
>
> I have a question concerning routes:
> Is it possible to set up a route that looks for the ":controller" in a
> subdirectory (/admin/:controller/:action) of the controllers?
>
> By example:
> http://example.org/admin/controller/action,
> would resolve "/path/to/application/controllers/admin/controller.php"
> and execute controller::action
>
> I know that ZFW can work out of a subdirectory... but this is sort of
> a different situation, as I want both the root "/" and "/admin/"
> working off the same copy of ZFW.
>
> Kind regards,
> Peter Pistorius
>
>


--





---------------------------------------------------------------------
Sorry, This disclamer is auto added by FW's company
---------------------------------------------------------------------




























Si vous n'etes pas destinataires de ce message, merci d'avertir l'expediteur de 
l'erreur de distribution et de le detruire immediatement.
Ce message contient des informations confidentielles ou appartenant a La 
Francaise des Jeux. Il est etabli a l'intention exclusive de ses destinataires. 
Toute divulgation, utilisation, diffusion ou reproduction (totale ou partielle) 
de ce message ou des informations qu'il contient, doit etre prealablement 
autorisee.
Tout message electronique est susceptible d'alteration et son integrite ne peut 
etre assuree. La Francaise des Jeux decline toute responsabilite au titre de ce 
message s'il a ete modifie ou falsifie.

If you are not the intended recipient of this e-mail, please notify the sender 
of the wrong delivery and delete it immediately from your system.
This e-mail contains confidential information or information belonging to La 
Francaise des Jeux and is intended solely for the addressees. The unauthorised 
disclosure, use, dissemination or copying (either whole or partial) of this 
e-mail, or any information it contains, is prohibited.
E-mails are susceptible to alteration and their integrity cannot be guaranteed. 
La Francaise des Jeux shall not be liable for this e-mail if modified or 
falsified.

Reply via email to