• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Advanced Controller Routing (based on domain)

#1
[eluser]stealthify[/eluser]
Hi all,
First post, but long-time fan of CodeIgniter. While things have been smooth-sailing with CI for my previous adventures, my first question for you guys happens to be a doozy.

The Concept
One CI installation, one database, one application --> routed to from multiple domains --> domain determines the controller to route to (so multiple controllers, multiple languages, multiple views)

I understand that there are probably a few different ways to go about this, but the folder structure I decided upon was:

-----------------------------------------
application/
-- controllers/
---- sites/
------- domain1/
--------- home.php (domain1.com/)
--------- about.php (domain1.com/about)
------- domain2/
--------- home.php (domain2.com/)
--------- about.php (domain2.com/about)
---- home.php (default fallback)
---- about.php (default fallback)
-- language/
---- sites/
------- domain1/
--------- english/
------- domain2/
--------- english/
---- english/
-- views/
---- sites/
------- domain1/
--------- home.php
--------- about.php
------- domain2/
--------- home.php
--------- about.php
---- home.php
---- about.php

-----------------------------------------

I figured this was my best bet, since really all of my configs, helpers, models, libraries, etc will remain the same, no matter which domain I have routed to my CI install.

My Goal
After poking around and exploring how the current routing system works, my plan of action was to determine which domain the code is executing under, and then querying a database to gather some preliminary info on which controller to call (ie: the default fallback if it doesn't exist in the database, or if it is found, the appropriate controller in the 'controllers/sites/' directory).

My Progress
The idea sounds simple enough, and I know how to extract the domain and run a query based on this domain. From there, I also know how to run a check to make sure that the controller exists (ex: controllers/sites/domain1/home.php).

My Question
What I'm stuck on is trying to figure out where I need to start in order to tell CI to call my alternate controller as opposed to the default controller. Will something like this require a modification of the system core? Or is it override-able from my 'application/' folder?

Lastly, do any of you see any pitfalls to using this method? Is there a better way to go about this?

Thanks for the help guys, hope everyone had a great weekend.


Messages In This Thread
Advanced Controller Routing (based on domain) - by El Forum - 07-05-2011, 09:18 AM
Advanced Controller Routing (based on domain) - by El Forum - 07-05-2011, 09:19 PM
Advanced Controller Routing (based on domain) - by El Forum - 07-05-2011, 11:39 PM
Advanced Controller Routing (based on domain) - by El Forum - 07-06-2011, 12:02 AM
Advanced Controller Routing (based on domain) - by El Forum - 07-07-2011, 09:58 AM
Advanced Controller Routing (based on domain) - by El Forum - 07-07-2011, 10:23 AM
Advanced Controller Routing (based on domain) - by El Forum - 07-07-2011, 10:35 AM
Advanced Controller Routing (based on domain) - by El Forum - 07-07-2011, 10:41 AM
Advanced Controller Routing (based on domain) - by El Forum - 07-08-2011, 01:42 AM
Advanced Controller Routing (based on domain) - by El Forum - 07-08-2011, 07:07 AM
Advanced Controller Routing (based on domain) - by El Forum - 07-08-2011, 07:18 AM
Advanced Controller Routing (based on domain) - by El Forum - 07-08-2011, 07:43 AM
Advanced Controller Routing (based on domain) - by El Forum - 07-08-2011, 08:09 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.