To make it easier to use smarty, we can put the three steps "loading the Smarty template engine", "Creating a Smarty object", and "setting the parameters of a Smarty object" in a public PHP file, in the future, we can reuqire it directly, for example:
1. Create a main. php
Include smarty/Smarty. class. php;// The next time the program is transplanted, you only need to modify the ROOT point location ~Const DIR_SEP = DIRECTORY_SEPARATOR;Define (ROOT, D:. DIR_SEP._PHP _ Test. DIR_SEP.Test2.DIR_SEP)
frameworks, such as bootstrap and purecss, with their own responsive support.We recommend that you read the necessary knowledge for mobile webapp development.Http://www.qianduan.net/mobile-webapp-develop-essential-knowledge.html
II. environment construction
First, you need to create a ThinkPHP project that contains TPM. You can download TPM from the ThinkPHP official website or from github. The Github address is:Https://github.com/liu21st/extend/tree/master/Extend/Tool/TPMCopy the downloaded fi
, Config_File.class.php, and debug. tpl files to the dataobjects directory.
You also need to copy the core and plugins directories and all the contents. create several new directories named templates, templates_c, configs,
And cache.
Finally, the dataobjects directory contains:
| ---- Cache| ---- Configs| ---- Core| ---- Plugins| ---- Templates| ---- Templates_c
11/10/2004 11: 17 a.m.
.
11/10/2004 11: 17 a.m.
..
11/10/2004 11: 17 a.m.
Learning PHP cannot help but mention SMARTY. As a famous template program, SMARTY naturally has its advantages. The following is my learning experience!============================================First download the latest smarty in smarty.php.netPut the libs folder in your WEB directory, and I put it in smarty. The directory is as follows: e:/smarty/libsCreate the following folder in the smarty directory:Templates (put your template file here, that is, the t
responsive manner. We recommend that you understand the knowledge of responsive design. You can also combine some UI frameworks, such as bootstrap and purecss, with their own responsive support.We recommend that you read the necessary knowledge for mobile webapp development.Http://www.qianduan.net/mobile-webapp-develop-essential-knowledge.html
II. environment construction
First, you need to create a ThinkPHP project that contains TPM. You can download TPM from the ThinkPHP official website or f
To consolidate the Smarty template engine, the following steps are compatible with the I-mode version:One: application/common/conf/config.php add' Tmpl_engine_type ' => ' Smarty ',Two: Download Smarty template engine Download addresshttp://www.smarty.net/Put it under the Thinkphp\library\vendor.Because Onethink already has smarty class, inthinkphp/library/think/template/driver/smarty.class.phpPublic function Fetch ($templateFile, $var) {$templateFile = substr ($templateFile, strlen (Theme_path))
In order to more convenient use Smarty later, we can "load Smarty template engine", "Establish Smarty object", "Set parameters of Smarty object" Three steps into a common PHP file, in the future where we need to use the place we directly reuqire, you can, For example:
1. Establish a main.php
Include smarty/smarty.class.php;The next time you migrate, you only need to change the root pointing location ~Const DIR_SEP = directory_separator;Define (ROOT, D:. Dir_sep._php_test.dir_sep. TEST2.DIR_
. php without bom in UTF-8 in test/smarty and configure some member attributes of smarty.
1
Template_dir = SMARTY_ROOT. "/templates/"; // set the template file storage directory 6 $ tpl-> compile_dir = SMARTY_ROOT. "/templates_c/"; // Set the directory where the compiled files are stored. 7 $ tpl-> config_dir = SMARTY_ROOT. "/configs/"; // Set the configuration file storage directory 8 $
;return true;} else {Exit (Error: Please set variable name);}}Let's start by judging if the user has set the variable name, judging by Isset ($var) trim ($var)! =, trim ($var)! = To prevent the user from setting the variable name with a space. If the set variable is correct, we'll save it to the member variable _tpl_ The VARs.Display () methodThe display () method is the most important method in the stupid class, he is used to display and detect whether the template is updated, updated and then
files
We need to create a configuration file to overwrite the default member attributes of the Smarty class and name it smarty. conf. php, saved in the smarty directory, which script needs to use Smarty in the future, we just need to put smarty. conf. include php.
12345678910111213
Include ("./smarty/libs/Smarty. class. php ");Define ('smarty _ root', './SMARTY/tpls ');$ Tpl = new Smarty ();$ Tpl
Smarty Quick Start 2. To make it easier to use smarty, we can put the three steps "loading the Smarty template engine", "creating a Smarty object", and "setting the parameters of a Smarty object" in a public way to make it easier to use smarty in the future, we can put the three steps "loading the Smarty template engine", "creating a Smarty object", and "setting the parameters of a Smarty object" in a public php file, in the future, we can reuqire it directly, for example:
1. create a main. php
This article mainly introduces the usage of the PHP template engine Smarty built-in variable mediation, and analyzes in detail the definition and usage of common built-in variable regulators in Smarty based on the instance form, if you need it, refer to the example in this article to describe the usage of the PHP template engine Smarty built-in variable mediation. We will share this with you for your reference. The details are as follows:
The variable mediation in Smarty is equivalent to a func
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.