Just touch the smarty template, want to control the number of news displayed in the template, shown below 5 News
{section name=news loop= $arr max=5}
- {$arr [News].title}
{/section}
How to read the corresponding number of records in the PHP program according to the number of bars in the template? How do I get the number of bars set in my template?
Thus implementing the following SQL:
SELECT ID, title, wdate from news ORDER by ID DESC LIMIT 0, 5
Instead of:
SELECT ID, title, wdate from news ORDER by ID DESC
Reply to discussion (solution)
Is it not up to you to take a few? Just write it right ... limit 0,5
$smarty. Section.loop.index forget about this. You can tell the current operation is the first few
$smarty. Section.sectionname.index or that's it. Determine the number of rows in 1-5 direct. Otherwise, it does not run. The landlord search will know
{section name=news loop= $arr max=5}
- {$arr [News].title}
{/section}
I'm sorry, I don't understand, I mean, how do I get the max=5 defined in the template in PHP?
Define another variable that introduces the use of
Define another variable that introduces the use of
Can you make it a little more specific? Just contact, do not know how to define.
The Smarty cycle can be controlled and terminated, but it's not your type.
No interest in Smarty!
I know, it's really not my way of writing, usually after the data is ready to call the display template.