This article mainly introduces the method of wrapping a smarty table, which can be used to flexibly operate a table. For more information, see the example in this article. 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}>
| <{$ Item. name}> |
<{$ Item. summary}> |
<{$ Item. date}> | <{If ($ count + 1) is p by 2}>
<{/If}><{/Foreach}>
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}>
| <{$ Item. name}> | <{If ($ count + 1) is p by 3}>
<{/If}><{/Foreach}>
Another example is to use cycle for line feed. However, the effect of line feed can be changed only when there are two rows in each row.
The code is as follows:
<{Foreach item = item from = $ items}>
<{$ Item. name}>
<{Cycle values =" | ,
"}><{/Foreach}>
I hope this article will help you with PHP programming.