thinkphp Study Notes (13) multi-template support and multi-language support
The first is multi-template support:
You need to create a new red folder and the corresponding action HTML template above the TPL
conf.php
Multi-Template Support
' Tmpl_switch_on ' =>true,
' Tmpl_detect_theme ' =>true,
Index.html
Template One
Default
Multi-lingual Support:
confg.php
Multi-language support//whether to open multi-lingual support ' lang_switch_on ' =>true,//under the folder name to write ' Default_lang ' + ' ZH-CN ',//automatic detection language ' lang_auto_ DETECT ' =>true,
Create the corresponding folder language pack, all action public named common.php, for different action named different PHP files; for example user.php
Common code:
' Welcome ', ' lan ' = ' 中文版 ', ' usernamenull ' = ' username ' is null ', '; >
Set Language mode one in common
Design Language Method Two: Set in action, using the L function
Quick Setup Language// L (' demo ', ' Multi-language test ');
referencing and replacing text on a page
Welcome:
Language:
Demo
Chinese Simplified
中文版
Set how languages are used in model: ; need to add a leader character
For example, set prompt validation information in model
protected $_validate=array (//Add internationalized Array (' username ', ' require ', ', '
, 0,0,1) in the model, array (' username ', ' Checklen ', ' username length not valid ', 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 ', ' mailbox format not ', 0, ' Regex ', 1),);