external view folder ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: external view folder ? (/showthread.php?tid=6669) |
external view folder ? - El Forum - 03-07-2008 [eluser]n8m[/eluser] Hello, I'm looking for a possibility to set up a second view folder. This second folder should reside beneath the system folder in the toplevel. Right now, I'm using a view that simply includes another file (in the root folder level). / |-system | |-config | |-controllers | |-errors ... ... | |- views | | |->reroute.php | |-templates <- second view folder Is there a more elegant way to accomplish my task? The problem is that I want to keep my users out of the System folder. Thnx in advance n8m external view folder ? - El Forum - 03-07-2008 [eluser]Armchair Samurai[/eluser] If you want to keep your users out of the system folder, why not move it above the docroot? external view folder ? - El Forum - 03-08-2008 [eluser]Vince Stross[/eluser] I have accomplished this by extending the Loader class. The following would allow you to call your views from anywhere. I call mine from another folder on the server. I do this because my CI application is used on many different sites and this way I can have a single code base. create a file called, MY_Loader.php in your application/libraries folder with the following code: Code: <?php You would use this in your controller like so: Code: $this->load->my_view('<view file>','<view path>',$data,true/false); The functionality is exactly the same as $this->load->view(); except you can specify a path to pull the view file from without hacking the core. The beauty of doing it this way is that you can still use the '$this->load->view()' function when you want to and use '$this->load->my_view()' when you want to get tricky! If you're not familiar with extending core libraries: just an FYI, there is no reason to explicity load anything - your function is available as long as the prefix is set right in the config.php file and your file name is exactly the same. (i.e. 'MY_Loader.php' (correct) versus 'my_loader.php' (wrong) or 'MY_loader.php' (wrong)) Enjoy! external view folder ? - El Forum - 03-08-2008 [eluser]Avatar[/eluser] if you use linux you can do this from command prompt and it will just work. Code: cd /path/to/docroot in my application folder and my system folder (if you moved application out of system, otherwise just system)I have a h.taccess file with this in it: Code: option -indexes Code: Allow from all external view folder ? - El Forum - 03-08-2008 [eluser]n8m[/eluser] Wow, thnx for all the response. @BeyondCiv: This looks like perfect! Thanks for that. @yingyes: Unfortunatly I have no shell access to this server. external view folder ? - El Forum - 03-08-2008 [eluser]Vince Stross[/eluser] glad to help... just so you know though, you could still do what yingyes proposes by creating your links with PHP. I use shared hosting that runs on Linux and they told me I couldn't have shell access to create sym links. Well, check the PHP docs at : http://us.php.net/manual/en/function.symlink.ph The 'symlink()' function does it just fine! If you are interested in hard links, there's a function for that too. Read this doc page: http://us.php.net/manual/en/function.link.php. I prefer to use the extended library method because it will work on any platform and doesn't require creating links when moving the application to a different server, etc. |