Welcome Guest, Not a member yet? Register   Sign In
Dynamic Routing
#1

[eluser]deepakaggarwal[/eluser]
I'm trying to create an application where an organization can register to get their isolated application instance (logically). Physically the same application will be shared (SaaS).

So, when an organization registers themselves on a form, I want to provide them a login URL such as "http://www.somesite.com/{organizationId}/{Controller}/{Action}"
Initially it would be like:
http://www.somesite.com/1/login/index

There are now 2 parts:
1. I do not want index.php. That I can handle in .htaccess file I guess.
2. Actual query: How do I insert a dummy {organizationId} in login route? I went through docs and there is some static option to map explicit routes in config file. But I wouldn't wish to do a manual entry for every organization and rather have it dynamic.

Once user has logged in from login page, I wanna keep normal url (without organizatgionId) as I can always put Organization ID in session after login.

please suggest on how can I achieve this.
thanks
#2

[eluser]ranjudsokomora[/eluser]
Good Day deepakaggarwal,
You can do what you are requesting but I believe it may be easier to construct your url like this:
"http://www.somesite.com/{Controller}/{Action}/{organizationID}"

You can then pull organizationID from the action function as a parameter.

#3

[eluser]Rolly1971[/eluser]
you can try setting up a route in routes.php like this:

Code:
$route['(:num)/login/index'] = "login/index";

then in your "login/index" function grab the uri segment:

Code:
$organizationID = $this->uri->segment(1);
#4

[eluser]deepakaggarwal[/eluser]
Thanks for the suggestions. There is a slight change. Though I mentioned that I need OrganizationId only during login and later I can put it in session. But! What if session expires? In that case I would need to redirect user back to the login screen (where I need OrganizationId).

So I think, OrganizationID has to be there in each and every request. So, all routes will be like:

http://www.somesite.com/{organizationId}...rArguments}
OR as another suggestion above:
http://www.somesite.com/{Controller}/{Ac...rArguments}

I'll try all above comments and will post what I eventually used. Meanwhile, if anyone gets another thought, please share!

Thanks a lot Guys Smile




Theme © iAndrew 2016 - Forum software by © MyBB