discuz! template file positioning under normal circumstances
Template file Directory
Under special circumstances
Under special circumstances
Understanding PHP's include mechanism header file
1 2 3 4 5 6 7 |
<! DOCTYPE HTML!> > > <meta CharSet="Utf-8"> > > <body> |
Master File
1 2 3 |
<?php include ' head.php ' ?> <p> here is the content </p> <?php include ' foot.php ' ?> |
Tail file
discuz! X sub-template call label
Role: By calling the sub-template, to achieve the template separation, improve the template reuse rate.
How to use:
Template sub-template directory/Sub-template file name
Subtemplate sub-template directory/Sub-template file name
Subtemplate more efficient than template execution
1 2 3 |
<!--{Template Common/header}-- <p> Content </p> <!--{Template common/footer} -- |
discuz! X variable output label
Function: Output variable value, support multidimensional array, variable nesting way.
Use method: {$ variable name} or variable name
1 2 3 4 |
<!--{Template Common/header}-- <p>{$_g[' uid ']}</p> User ID value <p>{$_g[' username ']}</p> user name <!--{Template common/footer} -- |
discuz! x constant Output label
Function: output constant value
How to use: {constant name}
1 2 3 4 |
<!--{Template Common/header}-- <p>{TIMESTAMP}</p> timestamp of current time <p>{discuz_root}</p> absolute path to root directory <!--{Template common/footer} -- |
discuz! X Universal Output Label
Output arbitrary values, support variables, constants, functions, Object Properties, Object methods, PHP statements, etc.
How to use: {Echo output code}
1 2 3 4 5 |
<!--{Template Common/Header}- <p>{echo $_g[ ' username ' ]}</p> user name <p>{echo ' PPC ' }</p> standard string <p >{echo 1+ 2}</p> output value 3 <!--{template common/footer} --> |
discuz! X run a single-line code label
Function: Execute arbitrary single-line PHP code
How to use: {eval any PHP code}
1 2 3 4 |
<!--{Template Common/header}-- {eval $phpchina = ' PPC '} assigns PPC to Phpchina <p>{phpchina}</p> Output PPC <!--{Template common/footer} -- |
discuz! X run multiple lines of code labels
Function: Execute arbitrary multiple lines of PHP code
How to use: {ecal}php code {/ecal}
1 2 3 4 5 6 7 |
<!--{Template Common/Header}--> {eval }function phpchina ({ echo ' This is PHP CHIAN function ' {/eval } <p>{eval phpchina< Span class= "Br0" > () }</p> Output Phpchina value <!--{template common/footer }--> |
Note The dzx2.5 version can use eval
discuz! X Output Avatar Label
Function: Output The specified user ID avatar, support large medium and small three kinds of size
How to use:
1 2 3 4 5 6 7 8 |
{Avatar(User ID,' Big ')} {Avatar(User ID,' Medium ')} {Avatar(User ID,' Small ') <!--{template common/ header }--> {avatar (1 , ' big ' ) } call the big head like { Avatar (1, ' Medium ' {avatar (1,< Span class= "st_h" > ' small ' ) } called small avatar <!-- {template common/footer}--> |
discuz! X Loop Value Label
Function: Traverse the data stored in the PHP array
How to use:
{Loop $ array name $ value} {/loop}
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<!--{Template Common/Header}- {Eval} $phpchina=Array( ' AA '= ' dz ' ' BB ' => ' ZD ' {/eval } <ul> {loop $phpchina $value } <li> { $value }</li> </loop> </ul> Span class= "sy0" ><!--{template common/footer} --> |
{Loop $ array name $ index $ value} {/loop}
1 2 3 4 5 |
<ul> {Loop $phpchina $key $value} <li>{$key} {$value}</li> </loop> </ul> |
discuz! X Logical Judgment Label
Role: Achieve highly customized Process control processing
How to use:
1 2 3 4 |
{if Condition } {ElseIf condition } {Else} {/if} |
first, the output 1 when the display "value is 1"
1 2 3 4 5 6 |
<!--{template common/header }-- {eval $phpchina = 1} {if $phpchina ==1} Value is 1 {/if} <!--{template common/footer} --> |
Second, if execution fails to execute {else}
1 2 3 4 5 6 7 8 |
<!--{template common/header }--> {eval < Span class= "RE0" > $phpchina = 2} {if $phpchina == 1} value is 1 {else< Span class= "Br0" >} value is not 1 {/if <!--{template common/footer }--> |
Third, when 1 is displayed "value is 1", the value is 2 when the display "values are 2", no from "not 1, nor 2"
1 2 3 4 5 6 7 8 9 |
<!--{Template Common/Header}- {Eval $phpchina = 2} {if $phpchina = =1} Value is 1 {ElseIf $phpchina = =2} {Else} Not 1, not 2. {/if} <!--{Template common/footer} -- |
discuz! X3.1 label use (i)