Loop Output
Volist also has an alias iterate
Template Assignment:
$User = D (' User ')
$list = $User->findall ()
$this->assign (' list ', $list)
Template Definition:
<iterate name= "list" id= "vo" >
{$vo. name}
</iterate>
Note the meaning of the name and ID representation
//output List 5th to 15th record
<iterate name= "list" id= "vo" offset= "5" length= ' >
{$vo. name}
</iterate>
//output even record
<iterate name= "list" id= "vo" mod= "2" >
<eq name= "mod" value= "1" >
{$vo. name}
</eq>
</iterate>
//output Key
<iterate name= "list" id= "vo" key= "k" >
{$k}. {$vo. name}
</iterate>
//sub-loop Output
<volist name= "list" id= "vo" >
<iterate name= "vo[' sub ']" id= "sub" >
{$sub. name}
</iterate>
</volist>
Switch Label
<switch name= "name" >
<case value= "1" >value1</case>
<case value= "2" >value2</case>
<default/>default
</switch>
where the Name property can use functions and system variables , for example:
<switch name= "think.get.userid|abs" >
<case value= "1" >admin</case>
<default/>default
</switch>
You can also use variables for the Value property of the case, for Example:
<switch name= "userId" >
<case value= "$adminId" >admin</case>
<case value= "$memberId" >member</case>
<default/>default
</switch>
Compare Labels
<eq name= "name" value= "value" >value</eq>//name variable values equal to the output
<neq name= "name" value= "value" >value</neq>//name variable values are not equal to value output
<gt name= "name" value= "5" >value</gt>//the value of the name variable is greater than 5 for output
<egt name= "name" value= "5" >value</egt>//the value of the name variable is greater than or equal to 5 for output
<lt name= "name" value= "5" >value</lt>//the value of the name variable is less than 5 for output
<elt name= "name" value= "5" >value</elt>//the value of the name variable is less than or equal to 5 for output
//actually All of the above tags are aliases of compare tags
//where The value of the type attribute is the name of the judging tag listed above
<compare name= "name" value= "5" type= "eq" >value</compare>//the value of the name variable equals 5 on output
if label
<if condition= "$name eq 1" > value1
<elseif condition= "$name eq 2"/>value2
<else/> value3
</if>
C Operation
operation (dynamic) Configuration: mainly used in the action method
get:
C (' configuration Parameters ')
settings:
C (' config parameter ', new Value)
a Operation
to quickly create an action object:
$action = A (' User ');
is equivalent to
$action = new Useraction ();
D Operation
to quickly create a model data object:
$model = D (' User ');
is equivalent to
$model = new Usermodel ();
s Operation
Quick-action Caching Method
get:
S (' name ')
settings:
S (' name ', ' Value ');
delete:
S (' name ', NULL);
F Operation
How to save fast file data
use the same method as the S operation
L Operation
quickly manipulate language variables
get:
L (' language variable ');
settings:
L (' language variable ', ' value ');
such as: L (' user_info ', ' user information ');//set language variable with name User_info
Batch Assignment:
$arr [' language variable 1 '] = ' value 1 ';
$arr [' language variable 2 '] = ' Value 2 ';
L ($arr);
thinkphp System Constants
think_path//thinkphp System Directory
app_path//current project Directory
app_name//current Project Name
module_name//current Module Name
action_name//current operation name
tmpl_path//project Template Catalog
Lib_path//project Class Library Directory
cache_path//project Template Cache directory
config_path//project configuration file directory
log_path//project log file directory
lang_path//project Language file directory
temp_path//project temp file directory
plugin_path//project plug-in file directory
Vendor_path//third-party Class Library Directory
data_path//project data File directory
Is_apache//whether It belongs to APACHE
Is_iis//whether It belongs to IIS
Is_win//whether It belongs to the Windows environment
Is_linux//whether It belongs to LINUX environment
Is_freebsd//whether It belongs to FREEBSD environment
now_time//current timestamp
Memory_limit_on//whether There is a memory usage limit
Memory_limit_on//whether There is a memory usage limit
output_gzip_on//whether to turn on output compression
MAGIC_QUOTES_GPC//MAGIC_QUOTES_GPC
think_version//thinkphp Version number
Lang_set//browser Language
template_name//current Template Name
template_path//current Template Path
__root__//website root directory address
__app__//current Project (entry File) address
__url__//current Module Address
__action__//current Operating Address
__self__//current URL Address
tmpl_file_name//default template name for the current operation (with Path)
web_public_url//website Public Directory
app_public_url//project Common Template Catalog
Pre-defined Constants
web_log_error=0//error Log Type
web_log_debug=1//debug Log Type
Sql_log_debug=2//SQL Log Type
System_log=0//system-mode Logging
Mail_log=1//mail Logging
Tcp_log=2//TCP Log logging
file_log=3//file Mode logging
data_type_obj=1//object mode return
Data_type_array=0//array mode return
url_common=0//normal mode URL
Url_pathinfo=1//PATHINFO URL
Url_rewrite=2//REWRITE URL
Has_one=1//has_one Association definition
Belongs_to=2//belongs_to Association definition
Has_many=3//has_many Association definition
Many_to_many=4//many_to_many Association definition
exists_vailidate = 0//form exists field is validated
must_validate = 1//must be verified
value_vailidate = 2//the form value is not NULL to validate
Summarize thinkphp experience sharing (ii.)