CodeIgniter is used to generate static pages. codeigniter is used to generate static pages.

Source: Internet
Author: User

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!'; }}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.