This post was last edited by cr180
In the DIY module template, there is such a judgment statement: [Index = N]... [/Index]
The following describes how to use this judgment statement!
Let's take a look at a DIY code example: [Index = 1] <A class = "style1" href = "{URL}" {target }>{ title} </a> [/Index] [Index = 2] <A class = "style2" href = "{URL}" {target }>{ title} </a> [/Index] [Loop] <A class = "style3" href = "{URL}" {target }>{ title} </a> [Loop]
The above code is the module code used in DIY. Generally, only the green section is written in the DIY module code, and the Code such as Index = x is rarely used. You may be unfamiliar with such code.
In fact, Index = x is also a judgment statement in DIY. What is it? Extract! Cut! Extracts the specified data from the cyclic data. The extracted data is not displayed in the loop label.
More intuitive:
A call statement reads 10 messages. The first one is red, the second one is blue, and the last eight are green.
In this way, we can use the index judgment statement to complete the process:
When the first title is currently used, use [class = "style1 "]
Use [class = "style2"] For the second title "]
For other titles, use [class = "style3 "]
In this way, we can use a single call statement to obtain multiple layout forms. From this, we can see that the considerations for DIY are still very comprehensive. The Unsupported custom SQL may involve complicated content, and the official version may be included in the plan for the next version.
Usually, judgment statements such as index may be often used in slides or advanced Template Techniques with special requirements.
|
Source: http://www.discuz.net/thread-1912061-1-1.html