• <style id="hgzg1"><delect id="hgzg1"><small id="hgzg1"></small></delect></style>
    <li id="hgzg1"><legend id="hgzg1"></legend></li>
        \n{$test.num|md5} \/\/ 原文這里也寫錯了\n
        \n{$tmp}\n<\/body>\n<\/html>\n\n<\/pre>\n\n

        Readers who are interested in more CodeIgniter-related content can check out the special topics of this site: \"Basic Tutorial for Getting Started with Smarty Templates\", \"Introductory Tutorial for CodeIgniter\", \"Advanced Tutorial for CI (CodeIgniter) Framework\", \"Summary of Excellent PHP Development Framework\" \", \"ThinkPHP introductory tutorial\", \"ThinkPHP common methods summary\", \"Zend FrameWork framework introductory tutorial\", \"php object-oriented programming introductory tutorial\", \"php mysql database operation introductory tutorial\" and \"php common database operation skills summary\" <\/p>\n

        I hope this article will be helpful to everyone’s PHP program design based on the CodeIgniter framework. <\/p>\n

        <\/p>\n

        \nhttp:\/\/www.bkjia.com\/PHPjc\/1127873.html<\/span>www.bkjia.com<\/span>true<\/span>http: \/\/www.bkjia.com\/PHPjc\/1127873.html<\/span>TechArticle<\/span>Analysis of the method of integrating Smarty with CI framework, ci framework integrating smarty This article describes the method of integrating Smarty with CI framework. Share it with everyone for your reference, the details are as follows: Because the template that comes with CI...<\/span>\n<\/div>\n
        <\/div>"}

        国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

        Table of Contents
        Analysis of the method of CI framework integrating Smarty, ci framework integrating smarty
        Home Backend Development PHP Tutorial Analysis of methods for CI framework integration with Smarty, CI framework integration with smarty_PHP tutorial

        Analysis of methods for CI framework integration with Smarty, CI framework integration with smarty_PHP tutorial

        Jul 12, 2016 am 08:52 AM
        ci framework smarty

        Analysis of the method of CI framework integrating Smarty, ci framework integrating smarty

        The example in this article describes the method of CI framework integrating Smarty. Share it with everyone for your reference, the details are as follows:

        Because the template function that comes with CI is not very convenient, people generally adopt the method of integrating Smarty to make up for the shortcomings of CI.

        I have read a lot of tutorials on CI integration with Smarty on the Internet, including a highlight post in our CI forum

        http://codeigniter.org.cn/forums/forum.php?mod=viewthread&tid=10345.

        After comparing these tutorials myself, I think the following plan is the best among them all, and I highly recommend it to everyone (of course it is also the plan I adopt myself)

        Source:

        http://www.cnmiss.cn/?p=261

        I have corrected some errors in the original article

        Let me talk about the reasons why I think it is better. Comparing this solution with the solution in our forum, you will find that this solution has one more advantage because it extends the core class,

        It extends the Smarty class methods assign and display to Ci's controller, so when we use Smarty in CI, we can use it like this:

        public function index()
        {
            //$this->load->view('welcome_message');
            $data['title'] = '標題';
            $data['num'] = '123456789';
            //$this->cismarty->assign('data',$data); // 也可以
            $this->assign('data',$data);
            $this->assign('tmp','hello');
            //$this->cismarty->display('test.html'); // 也可以
            $this->display('test.html');
        }
        
        

        Through the simple extension of the core controller class, when everyone uses Smarty in CI, the usage habits are the same as using Smarty directly. This is a great advantage.

        And judging from the expansion of the core class library, you can also see that the author of this article has a good understanding of the CI framework.

        According to this article, I not only successfully integrated Smaty, but also further strengthened my understanding of CI.

        Furthermore, this solution places Smarty’s configuration files in the config directory of the CI framework, and the use of both is very standardized.

        Finally achieved "the seamless combination of CI and Smaty".

        The following is the specific tutorial: // I made some modifications based on the original text and corrected some errors in the original text. Please note that the places with '//' below are the places that I have modified or modified by myself. Another place to add.

        CI version: 2.1.4 // (version used when this article was published)

        Smarty version: Smarty-2.6.26 // Because I have used this version before, in order to take care of my own usage habits, I do not use the latest Smaty version here. After everyone understands the expansion principle, you can choose the Smatry version you want to use.

        1. Go to the corresponding site to download the source code package of Smarty; // I am using Smarty-2.6.26

        2. Copy the libs folder in the source package to the libraries folder under the CI project directory, and rename it to Smarty-2.6.26; //

        3. Create a new file Cismarty.php in the libraries folder of the project directory. The contents are as follows:

        <&#63;php
        if(!defined('BASEPATH')) EXIT('No direct script asscess allowed');
        require_once( APPPATH . 'libraries/Smarty-2.6.26/libs/Smarty.class.php' );
        class Cismarty extends Smarty {
          protected $ci;
          public function __construct(){
            $this->ci = & get_instance();
            $this->ci->load->config('smarty');//加載smarty的配置文件
            //獲取相關的配置項
            $this->template_dir  = $this->ci->config->item('template_dir');
            $this->complie_dir  = $this->ci->config->item('compile_dir');
            $this->cache_dir   = $this->ci->config->item('cache_dir');
            $this->config_dir   = $this->ci->config->item('config_dir');
            $this->template_ext  = $this->ci->config->item('template_ext');
            $this->caching    = $this->ci->config->item('caching');
            $this->cache_lifetime = $this->ci->config->item('lefttime');
          }
        }
        
        

        4. Create a new smart.php file in the config folder of the project directory. The content is as follows:

        <&#63;php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
        $config['theme']    = 'default';
        $config['template_dir'] = APPPATH . 'views';
        $config['compile_dir'] = FCPATH . 'templates_c';
        $config['cache_dir']  = FCPATH . 'cache';
        $config['config_dir']  = FCPATH . 'configs';
        $config['template_ext'] = '.html';
        $config['caching']   = false;
        $config['lefttime']   = 60;
        
        

        5. Create new folders templates_c, cache, configs in the directory where the entry file is located;

        6. Find the autoload.php file in the config directory under the project directory
        Edit this

        $autoload['libraries'] = array('Cismarty');
        //目的是:讓系統(tǒng)運行時,自動加載,不用人為的在控制器中手動加載
        
        

        7. Create a new file MY_Controller.php in the core folder of the project directory. The content is as follows: // Extend the core control class

        <&#63;php if (!defined('BASEPATH')) exit('No direct access allowed.');
        class MY_Controller extends CI_Controller { // 原文這里寫錯
          public function __construct() {
            parent::__construct();
          }
          public function assign($key,$val) {
            $this->cismarty->assign($key,$val);
          }
          public function display($html) {
            $this->cismarty->display($html);
          }
        }
        
        

        Configuration completed

        Usage example:

        in the controller like:

        <&#63;php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
        class Welcome extends MY_Controller { // 原文這里寫錯
          public function index()
          {
            //$this->load->view('welcome_message');
            $data['title'] = '標題';
            $data['num'] = '123456789';
            //$this->cismarty->assign('data',$data); // 亦可
            $this->assign('data',$data);
            $this->assign('tmp','hello');
            //$this->cismarty->display('test.html'); // 亦可
            $this->display('test.html');
          }
        }
        
        

        Then in the view: the view folder is located under views in the project directory:

        New file test.html

        <!DOCTYPE html>
        <html>
        <head>
        <meta charset="utf-8">
        <title>{ $test.title}</title> //( 原文是 <title>{$test['title']}</title>,是錯誤的寫法,也有可能是Smarty版本的原因)
        <style type="text/css">
        </style>
        </head>
        <body>
        {$test.num|md5} // 原文這里也寫錯了
        <br>
        {$tmp}
        </body>
        </html>
        
        

        Readers who are interested in more CodeIgniter-related content can check out the special topics of this site: "Basic Tutorial for Getting Started with Smarty Templates", "Introductory Tutorial for CodeIgniter", "Advanced Tutorial for CI (CodeIgniter) Framework", "Summary of Excellent PHP Development Framework" ", "ThinkPHP introductory tutorial", "ThinkPHP common methods summary", "Zend FrameWork framework introductory tutorial", "php object-oriented programming introductory tutorial", "php mysql database operation introductory tutorial" and "php common database operation skills summary"

        I hope this article will be helpful to everyone’s PHP program design based on the CodeIgniter framework.

        www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1127873.htmlTechArticleAnalysis of the method of integrating Smarty with CI framework, ci framework integrating smarty This article describes the method of integrating Smarty with CI framework. Share it with everyone for your reference, the details are as follows: Because the template that comes with CI...
        Statement of this Website
        The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

        Hot AI Tools

        Undress AI Tool

        Undress AI Tool

        Undress images for free

        Undresser.AI Undress

        Undresser.AI Undress

        AI-powered app for creating realistic nude photos

        AI Clothes Remover

        AI Clothes Remover

        Online AI tool for removing clothes from photos.

        Clothoff.io

        Clothoff.io

        AI clothes remover

        Video Face Swap

        Video Face Swap

        Swap faces in any video effortlessly with our completely free AI face swap tool!

        Hot Tools

        Notepad++7.3.1

        Notepad++7.3.1

        Easy-to-use and free code editor

        SublimeText3 Chinese version

        SublimeText3 Chinese version

        Chinese version, very easy to use

        Zend Studio 13.0.1

        Zend Studio 13.0.1

        Powerful PHP integrated development environment

        Dreamweaver CS6

        Dreamweaver CS6

        Visual web development tools

        SublimeText3 Mac version

        SublimeText3 Mac version

        God-level code editing software (SublimeText3)

        How to use CI framework in php? How to use CI framework in php? Jun 01, 2023 am 08:48 AM

        With the development of network technology, PHP has become one of the important tools for Web development. One of the popular PHP frameworks - CodeIgniter (hereinafter referred to as CI) has also received more and more attention and use. Today, we will take a look at how to use the CI framework. 1. Install the CI framework First, we need to download the CI framework and install it. Download the latest version of the CI framework compressed package from CI's official website (https://codeigniter.com/). After the download is complete, unzip

        How to use CI framework in PHP How to use CI framework in PHP Jun 27, 2023 pm 04:51 PM

        PHP is a popular programming language that is widely used in web development. The CI (CodeIgniter) framework is one of the most popular frameworks in PHP. It provides a complete set of ready-made tools and function libraries, as well as some popular design patterns, allowing developers to develop Web applications more efficiently. This article will introduce the basic steps and methods of developing PHP applications using the CI framework. Understand the basic concepts and structures of the CI framework. Before using the CI framework, we need to understand some basic concepts and structures. Down

        How to use CI4 framework in php? How to use CI4 framework in php? Jun 01, 2023 pm 02:40 PM

        PHP is a widely used server-side scripting language, and CodeIgniter4 (CI4) is a popular PHP framework that provides a fast and excellent way to build web applications. In this article, we will get you started using the CI4 framework to develop outstanding web applications by walking you through how to use it. 1. Download and install CI4 First, you need to download it from the official website (https://codeigniter.com/downloa

        How to use Smarty template engine in PHP development How to use Smarty template engine in PHP development Jun 27, 2023 pm 01:28 PM

        As a PHP developer, using a template engine is a natural choice. Smarty is a popular template engine that provides a way to separate HTML/CSS/JavaScript from PHP code, allowing developers to better organize and manage projects. In this article, we will learn how to use Smarty template engine during PHP development. 1. Install Smarty Before, we must install Smarty. In this article we will use Composer to install

        A preliminary study on the template engine Smarty in PHP A preliminary study on the template engine Smarty in PHP May 11, 2023 pm 05:15 PM

        Nowadays, website development is inseparable from an important component-template engine. A template engine refers to a tool that combines page templates and data to generate HTML code with a specific format. In various website development frameworks, the template engine is an essential component, because the template engine can greatly reduce the duplication of code and improve the dynamics of the page. One of the most common and popular template engines is Smarty. Smarty is a DSL (DomainSpecif

        How to use PHP and Smarty to achieve front-end and back-end separation development How to use PHP and Smarty to achieve front-end and back-end separation development Jun 25, 2023 pm 01:46 PM

        In modern web development, the separation of front-end and back-end has become a very popular trend, which allows developers to better organize projects and improve the efficiency of project development. PHP and Smarty are two very commonly used technologies, which can be used to achieve front-end and back-end separation development. This article will introduce how to use PHP and Smarty to achieve front-end and back-end separation development. What is front-end and back-end separation development? In traditional web development, the front-end is mainly responsible for the presentation of the page and the logic of interaction with the back-end. The backend is mainly responsible for the business

        A guide to CI frameworks in PHP A guide to CI frameworks in PHP May 22, 2023 pm 07:10 PM

        With the development of the Internet and its continuous integration into people's lives, the development of network applications has become more and more important. As a well-known programming language, PHP has become one of the preferred languages ??for developing Internet applications. Developers can use numerous PHP frameworks to simplify the development process, one of the most popular is the CodeIgniter (CI) framework. CI is a powerful PHP web application framework. It has the characteristics of lightweight, easy to use, optimized performance, etc., allowing developers to quickly build

        How to introduce css into ci framework How to introduce css into ci framework Dec 26, 2023 pm 05:20 PM

        The steps to introduce CSS styles in the CI framework are as follows: 1. Prepare CSS files; 2. Store the CSS files in the appropriate location of the CI framework project; 3. In the pages that need to use CSS styles, introduce CSS through the HTML <link> tag File; 4. Use the CSS class or ID name in the HTML element to apply the corresponding style.

        See all articles