CI Framework Integration Smarty steps, CI framework smarty Detailed _php tutorial

Source: Internet
Author: User
Tags autoload codeigniter smarty template zend framework

CI Framework Integration Smarty steps, CI framework smarty Detailed


In this paper, the CI Framework integration smarty step is described in detail. Share to everyone for your reference, as follows:

CI combined with smarty configuration steps:

1. The first step is to configure CI and download Smarty template for personal liking (Smarty-3.1.8) this version.

2. The second part of the download to the Smarty version of the extract and then renamed the Libs file in Smarty and then copy the file to the Ci\application\libraries directory

3. Under Ci\application\libraries This directory to create a file, the file name can be customized, for example, see a tp.php document.

4. Open tp.php with the compiler and write the following code:

<?PHPIF (Defined (' BasePath ')) exit (' No Direct script access allowed '); require_once (' smarty/smarty.class.php '); Class TP extends smarty{function tp () {  parent::smarty ();  $this->template_dir = APPPATH. ' Views ';  $this->compile_dir = APPPATH. ' templates_c/';  $this->left_delimiter = ' <{';  $this->right_delimiter = '}> '; }}

5. In creating a Ci\application\templates_c folder

6. Open the ci\application\config\autoload.php file

$autoload [' libraries '] = array ();

Change to:

$autoload [' libraries '] = Array (' database ', ' TP ');

OK our configuration here has been successful, then we start to test

The first step in the test is to establish a controller:

1. Under \application\controllers, create a file named Ceshi.php, the contents of the file

<?PHPIF (Defined (' BasePath ')) exit (' No Direct script access allowed '); class Home extends Ci_controller {  functio n __construct ()  {   parent::__construct ();   $this->load->helper (' url ');   $this->tp->assign (' Base_url ', Base_url ());   Define CSS and JS path  }  function Index ()  {   $this->tp->assign ("title", "Congratulations on Smarty Installation success!") ");   $this->tp->assign ("Body", "Welcome to use Smarty template Engine");   $arr = Array (1=> ' Zhang ',2=> ' Xing ',3=> ' Wang ');   $this->tp->assign ("MyArray", $arr);   $this->tp->display (' ceshi.html ');}  }

2. Create a template file in the Ci\application\views directory to create a file named Ceshi.html, the file content is

  
 
    
 
  Smarty Installation Test

<{$title}>

<{$body}>

    <{foreach from= $myarray item=v}>
  • <{$v}>
  • <{/foreach}>

Finally enter the address Http://localhost/ci/application/index.php/ceshi (The idea CI represents the root of the file you put in the CI Framework yourself) and you will see the page where you configure Smarty success, Here, the integration and testing of CI and Smarty is complete.

More interested in CodeIgniter related content readers can view this site topic: "Smarty Template Primer Basic Tutorial", "CodeIgniter Introductory Tutorial", "CI (codeigniter) Framework Advanced Tutorial", "PHP Excellent Development Framework Summary", " thinkphp Introductory Tutorial, "Summary of common methods of thinkphp", "Introduction to the Zend Framework Framework", "Introduction to PHP Object-oriented Programming", "Introduction to Php+mysql Database Operations" and "PHP Common Database Operations Skills Summary"

It is hoped that this article is helpful to the PHP program design based on CodeIgniter framework.

http://www.bkjia.com/PHPjc/1127843.html www.bkjia.com true http://www.bkjia.com/PHPjc/1127843.html techarticle CI Framework Integration smarty steps in detail, CI framework smarty Detailed This article describes the CI framework integration smarty steps. Share to everyone for your reference, as follows: CI combined with smarty configuration steps ...

  • Related Article

    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.