One Application folder, many view folders..

#1
[eluser]mr_madness[/eluser]
Hi guys..

so, uhmm, i'd like to thank the CodeIgniter staff for creating this wonderful framework, it has been helping me quite a bit lately to build my app's way faster than before and with superb quality Big Grin


i have a question, as the topic title says, but i will try to explain my situation first, so you have an idea of what i want exactly:

I made an app with a frontend and a backend. The intention of this app is to serve many websites and they will all be hosted on a server I own. Their models and controllers will be all exactly the same, as they will all have the same functionality. Now to my question... I managed to have a system folder outside of the webroot, and this same system folder serves all applications.

Now, what i wanna do is have the same thing with the application folder. That is, have just 1 application folder, serving many view folders, which will be determined by the domain a client enters.

For example, if a client enters in example1 . com, CI will automatically use the folder "example1" for the views.
Someone else goes to example2 . com and it's view folder will be "example2".. all using the same app folder, got it?


hope someone can help me as i've been searching but many of the ways posted on the web says i have to create many app folders, but for me this is not good, as i will keep updating this app from time to time, and having to copy controllers folder by folder don't sound that funny for me... neither organized lol. Tongue

thanks in advance, sorry for the bad english, and if you need a better explanation, just tell me, i'll try my best. :cheese:

Peace Smile

#2
[eluser]mr_madness[/eluser]
One more thing i forgot... each site has it's own database also, but they all work exactly the same way..

anyone ever did something like that and can help me through it ? I'm getting mad thinking on a way to get along with this >.<

maybe this question might sound too newbie for some of ya and actually i am one so forgive me. lol XD

thanks again

#3
[eluser]sean_THR[/eluser]
I recently did exactly what you are describing and when I get around to it I will be writing up a detailed blog on how I did it.

I can give you a quick rundown that will hopefully get you on the right track.

I'm running on CI2, but I don't see any reason that this won't work with 1.7. My first step was to override the _ci_load function from CI's core Loader.php using MY_Loader.php. There's a line where the view path is set and you can easily change that to whatever you need.

As far as running on separate DBs, I accomplished that by creating a master DB with details for all of my other site DBs. In MY_Controller.php's constructor, I connect to the master DB to pull the appropriate DB information and then load in the site specific database. There may be a better way to do this, but it worked for me.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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