Smarty table newline instance

Source: Internet
Author: User
Tags smarty table
This article mainly introduces the line feed method for smarty tables, which can be used to flexibly operate tables. For more information, see

This article mainly introduces the line feed method for smarty tables, which can be used to flexibly operate tables. For more information, see

This article describes how to implement line feed in a smarty table. Share it with you for your reference. The specific analysis is as follows:

Add key = count to foreach

The Code is as follows:









<{Foreach item = item from = $ items key = count}><{If $ count is p by 2}> <{/If}> <{If ($ count + 1) is p by 2}> <{/If}><{/Foreach}>
<{$ Item. name}> <{$ Item. summary}> <{$ Item. date}>

Put three <{$ item. name}> lines in each row, and change the parameter if you like to change the line feed!

The Code is as follows:







<{Foreach item = item from = $ items key = count}> <{If ($ count + 1) is p by 3}> <{/If}><{/Foreach}>
<{$ Item. name}>

Another example is to use cycle for line feed, but the effect of line feed can only be changed to two rows when only two rows of data are in each row.

The Code is as follows:







<{Foreach item = item from = $ items}> , "}><{/Foreach}>
<{$ Item. name}>
<{Cycle values ="


I hope this article will help you with PHP programming.

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.