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 // multiple templates support 'tmpl _ SWITCH_ON '=> true, 'tmpl _ DETECT_THEME' => true, index.html <a href = '? T = red'> TEMPLATE 1 </a> <br> <a href = '? T = default '> default </a> <br> 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] <? Php/*** Chinese file defined for global modules * 1: Template needs to be modified * 2: modify the configuration file **/return array ('Welcome '=> 'Welcome', 'lan '=> 'English ', 'usernamenable' => '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: <! -- {$ Think. lang. welcome} --> <br> language: <! -- {$ Think. lang. lan} --> <br> demo: <! -- {$ Think. lang. demo} --> <br> <a href = '? L = zh-cn '> Simplified Chinese </a> <br> <a href = '? L = en-us '> english </a> <br> set the language used in the Model: <! -- {% Welcom} -->; you need to add a leading character, for example, in the model, set the prompt for verification information [php] protected $ _ validate = array (// Add an internationalized array ('username', 'require ',' <! -- {% Welcom} --> ', 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 ),);

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.