Dynamic routing

Hi Yii people !

here is my problem : I would like to setup a webapp that could route a request depending in informations stored in the DB.

Let me explain.

The webapp provides modules dedicated to handle (display, modify,etc…) a specific type of objects which are all stored in a DB table. Depending on the object, a specific module is used, but this should not impact URL (routes). For instance :

assuming that :

Object ID 1 is handle by moduleA

Object ID 2 is handle by moduleB


URL routes resolution would be :

/Object/read?id=1 must route to moduleA/Object/read with GET parameter id = 1

/Object/read?id=2 must route to moduleB/Object/read with GET parameter id = 2


Now, do you have an idea how to achieve this ? I guess I’ll have to write my own UrlManager right ?

Thanks for your help.

I’ve tried to play with UrlManager and it works fine (more or less) . After the parseUrl, I just check if the route starts with a specific string (the symbolic Module Id) and if yes, use some GET variables to find out what is the real Module Id, replace it and done.

For instance :

url : index.pgp?r=/VirtualModuleId/site/view&id=12

route = /[color="#FF0000"]VirtualModuleId[/color]/site/view => /[color="#2E8B57"]realModuleId[/color]/site/view

mapping between virtualModuleId and realModuleId is done based on the GET[id] value, by my own UrlManager.

(a problem is that string ‘virtualModuleId’ should not be used to name a controller)

I I use the path format for URL, then it doesn’t work anymore.In this case, the url would look like this :


The main problem is not replacing the ‘VirtualModuleId’ string, but accessing GET variables. After the parseUrl, the _GET array is empty. From what I found, the _GET is populated very late, when the controller is created … and that’s too late to choose a module.

I’ll keep on searching (any help is welcome ;) )