Home >Backend Development >PHP Tutorial >ThinkPHP study notes multi-template support and multi-language support_PHP tutorial

ThinkPHP study notes multi-template support and multi-language support_PHP tutorial

WBOY
WBOYOriginal
2016-07-14 10:08:211157browse

The first is multi-template support:

You need to create a new red folder and the corresponding action html template on tpl
conf.php
//Multiple template support
'TMPL_SWITCH_ON'=>true,
'TMPL_DETECT_THEME'=>true,
index.html
Template 1
Default
Multi-language support:
confg.php
[php]
//Multi-language support
//Whether to enable multi-language support
'LANG_SWITCH_ON'=>true,
//Write the folder name under Anzhao Lang
'DEFAULT_LANG'=>'zh-cn',
//Automatically detect language
'LANG_AUTO_DETECT'=>true,
Create the corresponding folder language package. The common name for all actions is common.php, and different php files are named for different actions; such as user.php
ThinkPHP study notes multi-template support and multi-language support_PHP tutorial
common code:
[php]
/**
* Chinese files for global module definitions
* 1: The template needs to be modified
* 2: The configuration file needs to be modified
*
*/
return array(
'welcome'=>'welcome',
'lan'=>'english',
'usernamenull'=>'username is null',
);
?>
Set the language method 1 in common
Design language method 2: Set in Action, use L function
[php]
//Quickly set language
L('demo','Multi-language test');
Quote and replace text on the page
[html] www.2cto.com
Welcome:
Language:
demo:
Set the language method in the Model: ; You need to add the leading character
For example, set prompt verification information in the model
[php]
protected $_validate=array(
//Add internationalization to the model
array('username','require','',0,0,1),
array('username','checklen','Username length is illegal',0,'callback',3),
array('password','require','Username required',0,0,1),
array('repassword','require','Username required',0,0,1),
array('password','repassword','Password inconsistent',0,'confirm',1),
/ array('createip','email','The email format is incorrect',0,'regex',1),
);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477785.htmlTechArticleThe first is multi-template support: You need to create a new red folder and the corresponding action html template conf.php on the tpl. //Multiple templates support TMPL_SWITCH_ON=true, TMPL_DETECT_THEME=true, index.html a...
Statement:
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