Welcome Guest, Not a member yet? Register   Sign In
Question on sub-domains with CI and sharing resources
#1

[eluser]Unknown[/eluser]
Hello,

I have a site which is going to need a sub-domain that is also running a CI application. Both will be sharing one system folder and that's all good! But I was wondering if it were possible to have both these applications sharing a few Views? Both these sites would have their own separate application folders.

Is it possible to access views outside of your application folder? Or is their a better way to go about this?

Thanks for the help
#2

[eluser]Aken[/eluser]
View folder can be completely separate from application, if desired.
#3

[eluser]CroNiX[/eluser]
Yes you can set the view directory within index.php just like the application and system directories. You could also just use symlinks.
#4

[eluser]Unknown[/eluser]
Thanks for the replies guys,

But could I access a separate Views folder that holds common templates? For instance, the application folder of site1 and site2 has all the View templates that are unique to it, but then to also have a "common" folder outside of these application folders that can be accessed by site1 and site2 when needed.

#5

[eluser]CroNiX[/eluser]
the load::view() will only look in one directory. So you could use that to load the unique views from each /application/views folder. But you'd either have to extend the loader class to also look in an additional separate location (for your common views), or just load THOSE like a regular file, using load::file() instead of load::view(). Of course you'd have to parse any variables on your own then as you can't pass data to anything you load::file() like you do when loading a view.

You could also extend CI with a MY_Loader and create an additional method for loading your common views, basically copying the code for load::view() except altering it with your own path. Maybe define() your common view path in the index.php of each app so it's not hardcoded in the extended class. I'd probably lean towards that as then you can pass data to your common views just like the regular application views.




Theme © iAndrew 2016 - Forum software by © MyBB