Introduction and Usage Analysis of smarty section

Source: Internet
Author: User

Basic prototype:
{Section name = name loop = $ varName [, start = $ start, step = $ step, max = $ max, show = true]}
Name: section name, no need to add $
$ Loop: The variable to be recycled. in the program, use assign to operate the variable.
$ Start: subscript of the start loop. The subscript of the loop starts from 0 by default.
$ Step: increment of the mark in each loop
$ Max: Maximum loop subscript
$ Show: boolean type. determines whether to display this block. The default value is true.

Here is a glossary:
Loop subscript: Actually, its English name is index, which means index. Here I translate it into "subscript" for better understanding. It indicates the current loop index when the loop block is displayed. The default value starts from 0 and is affected by $ start. If $ start is set to 5, it will also count from 5, we used it in the template design section. This is an attribute of the current {section} and the call method is Smarty. section. sectionName. index. Here, sectionName refers to the name attribute in the function prototype.
The attribute values of the {section} block are:
1. index: the "loop subscript" introduced above. The default value is 0.
2. index_prev: the first value of the current underlying object. The default value is-1.
3. index_next: The next value of the current underlying object. The default value is 1.
4. first: whether it is the first next loop
5. last: whether it is the last loop
6. iteration: number of cycles
7. rownum: current row number, another alias of iteration
8. loop: the last cycle number, which can be used to count the number of cycles of a section after the section Block.
9. total: number of cycles. The number of cycles can be counted after the section.
10. show: it is included in the function declaration to determine whether the section is displayed.

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.