The in label and Range label of the thinkphp template is used to determine whether a template variable is within a range .
1.in Label
the thinkphp in label is used for a template variable within a range, using the following format:
<in name= "variable name" value= "value 1, value 2,..." > What to Output </in>
When used, set the variable in the module operation (e.g. Index/display) and assign it to the template:
$groupId = 1;
$this->assign ("GroupId", $groupId);
Template/tpl/default/index/display.html, use the in tag usage as follows:
<in name= "GroupId" value= "1,2,3" > Management Group </in>
To run the sample, you can output:
Manage groups
The PHP code for this example is equivalent to:
<?php
if (($groupId), explode (', ', "1,2,3")) {
echo ' management group ';
}
? >
Note: The value of a variable can also be a string or an array, and the value of a property can use a variable.
2.notin Label
There is also a notin tag corresponding to the in label, that is, the judgment is not within a range:
Use such as:
<notin name= "GroupId" value= "1,2,3" > Non-admin Group </notin>
The above two tag examples are combined to equate:
<in name= "GroupId" value= "1,2,3" > Management Group <else/> Non-management group </in>
3.range Label
thinkphp in and Notin tags can also be replaced with range labels, such as:
<range name= "GroupId" value= "1,2,3" type= "in" > Management Group </range>
The above example corresponds to the in tag, which is equivalent to the Notin label when the value of the Type property is Notin.