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 ...