CodeIgniter is used to generate static pages. codeigniter is used to generate static pages.
This example describes how CodeIgniter generates static pages. We will share this with you for your reference. The details are as follows:
Now let's develop how to make the CI framework generate static pages. The following code is directly posted:
$this->output->get_output();
Using this method, you can get the data to be output and save it for use. (when we create a news website, we often need to generate static HTML files ).
$string = $this->output->get_output();$this->load->helper('file');write_file('./lianglong_codeigniter.html', $string);
For example, if the page we want to output is the data after loading a view
$this->load->view('welcome_lianglong);
Join later
$this->output->get_output();
And store the value to a variable such as $ lianglong. Then use the write_file auxiliary function in the ci file to generate the FILE you want, as shown in the following example:
function sc(){ $this->load->helper('file'); $this->load->view('welcome_message'); $lianglong=$this->output->get_output(); if ( !write_file('./lianglongfile.html', $lianglong)) { echo 'Unable to write the file'; } else { echo 'File written!'; }}
Or:
function sc(){ $this->load->helper('file'); $liangdong=$this->load->view('welcome_message',$data,true); if ( !write_file('./lianglongfile.html', $lianglong)) { echo 'Unable to write the file'; } else { echo 'File written!'; }}