ThinkPHP learning notes multi-template and multi-language support
Source: Internet
Author: User
First, multi-template support: you need to create a red folder and the corresponding action html template conf On The tpl. php // Configure & lt; a is first supported by multiple templates: you need to create a red folder and the corresponding action html template conf On The tpl. php // multiple templates 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 'default _ Lang '=> 'zh-cn' according to the folder name under LANG, // The Automatic detection language 'Lang _ AUTO_DETECT' => true, create the corresponding folder language pack. all actions are named common. php: name different php files for different actions, such as user. php common code: [php] 'Welcome ', 'lan' => 'English', 'usernamenull '=> 'username is Null',);?> Set language method 1 set design language in common Method 2: Set in Action, use the L function [php] // Quick setting language L ('demo ', 'multilingual test'); reference and replace the text on the page [html] www.2cto.com welcome:
Language:
Demo:
Simplified Chinese
English
Set the language used in the Model: ; You need to add a leading character, for example, to set the prompt for verification information in the model [php] protected $ _ validate = array (// add an international array ('username ', 'require ',' ', 0, 0, 1), array ('username', 'checklen', 'invalid username length', 0, 'callback', 3), array ('password ', 'require ', 'username mandatory', 1), array ('repassword', 'require ', 'username mandatory', 1 ), array ('password', 'repassword', 'inconsistent password', 0, 'firm', 1),/array ('createip', 'address ', 'wrong email format ', 0, 'regex', 1 ),);
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service