Where is the "best practice" place to put include files (inc.php) when using the Codeigniter framework?
Then in the middle of the file edit the two variables $application_folder and $system_path and make sure you're using an absolute path instead of a relative one. Then in your external PHP script just include the external. php file and use the $CI global object to access the whole codeigniter: include '../../external.
Load a nested view inside the controllerLoad the view in advance and pass to the other view. First put this in the controller: <? php // the "TRUE" argument tells it to return the content, rather than display it immediately $data['menu'] = $this->load->view('menu', NULL, TRUE); $this->load->view ('home', $data); ?>
The File Helper file contains functions that assist in working with files. Loading this Helper. Available Functions.
Since you are asking for "best practice", let me give you a long answer:
It's depend what is your included file is about. Since you are using a framework, CodeIginter have defined various places for you to place your library, helper, config, template, etc. It's better to stick to what the framework offers or you won't benefit from it.
It's all about the maintainability, the structure of your app, etc. Don't use a framework unless you are intend to understand them. Use library instead if you are only looking to reuse functionality that people have written.
Mark, put your include files in the view directory as long as they are html, xhtml, php etc. You can make directory's under the view directory to keep files in as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With