In this paper, the thinkphp support and multiple template support are briefly described in the form of examples. Thinkphp is a very important skill to share with you for your reference. Specifically as follows:
First, thinkphp multi-language support:
config.php configuration file Add:
Multi-language support settings
' lang_switch_on ' =>true,
' Default_lang ' => ' zh-cn ',
' Lang_auto_detect ' =>true,
' Lang_list ' => ' en-us,zh-cn,zh-tw ',
home/lang/folder to create three folders, respectively, ZH-CN, en-US, ZH-TW, respectively, on behalf of Simplified Chinese, English, Traditional Chinese
Folders can be set up with the template corresponding to the file, or public files common.php
The zh-cn/common.php page is as follows:
<?php return
Array (
' welcome ' => ' Hello ',
' lan ' => ' Simplified Chinese '
);
? >
The en-us/common.php page is as follows:
<?php return
Array (
' welcome ' => ' How to Are you fine? ',
' LAN ' => ' 中文版 '
);
? >
The zh-tw/common.php page is as follows:
<?php return
Array (
' welcome ' => ' Hello ',
' lan ' => ' Simplified Chinese '
);
? >
The template index.php code is as follows:
Welcome: {$Think. lang.welcome} language: {$Think. Lang.lan}
<a href= "? l=zh-cn" rel= "external nofollow" > Simplified Chinese </a>
<a href= "? l=en-us" rel= "external nofollow" >english</a> <a href= "? l=zh-tw" rel= "external
nofollow "> Chinese </a>
Or in the action method directly defined: L (' demo ', ' Test '), so that in the template can be directly applied: {$Think. Lang.demo}
For the model, for example: Array (' uname ', ' Require ', ' user name must be filled in '), can be used so: Array (' uname ', ' require ', '%name ');
Second, thinkphp Multi-template support:
config.php configuration file Add:
Multi-template Support
' tmpl_switch_on ' =>true,
' Tmpl_detect_theme ' =>true,
/home/tpl/Create other skin folders, such as Folder red, where the files are the same as in the default file.
To add in the template file:
<a href= "? t=red" rel= "external nofollow" > Red </a> <a href= "T=default" rel= "external nofollow
" > Default </a>
It is believed that the example mentioned in this article is helpful to thinkphp learning and developing.