Welcome Guest, Not a member yet? Register   Sign In
How to include a .html file in my CI-site
#1

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  
Manikanta
Reply
#2

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.
Jamie Bond
Full time International Development undergraduate.
Part time website developer.
Reply
#3

You have to rename your .html to .php and include it.

Reply
#4

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");
$this->load->view("gap_view");
$this->load->view("slider_view"); 


Good luck.
Reply
#5

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."
Jamie Bond
Full time International Development undergraduate.
Part time website developer.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB