![]() |
How to include a .html file in my CI-site - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: How to include a .html file in my CI-site (/showthread.php?tid=711) |
How to include a .html file in my CI-site - Chandini - 01-08-2015 Hai friends How to include a .html file into codeigniter .. I have a slider folder with 2 subfolder and 1 .html file .. these are in views folder .. these html .. how to include in controller page .. these are controller page <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Site extends CI_Controller { public function index() { $this->home(); } public function home() { $this->load->view("header.php"); $this->load->view("gap.php"); $this->load->view("slider.html"); } } but this is not working RE: How to include a .html file in my CI-site - Jamie - 01-08-2015 Please expand on your definition of not working, does it produce any errors? Do you have any errors in your logs? I would also say that it is bad practice to keep your assets (images, css & javascript) within your views folder. RE: How to include a .html file in my CI-site - Rufnex - 01-08-2015 You have to rename your .html to .php and include it. RE: How to include a .html file in my CI-site - Avenirer - 01-08-2015 Just as @Rufnex said: change the extension from .html to .php. A good advice (good practice) would be to also rename them to include "_view" in the names. So, header_view.php, gap_view.php and slider_view.php. Also, when you call the views, you call them without mentioning the extensions: PHP Code: $this->load->view("header_view"); Good luck. RE: How to include a .html file in my CI-site - Jamie - 01-08-2015 Whilst I completely agree with changing the extension of the file, according to the documentation you can use $this->load->view() to include files other than those with the .php extension? So surely this will include the html file? "The first parameter is required. It is the name of the view file you would like to load. Note: The .php file extension does not need to be specified unless you use something other than .php." |