View previous topic :: View next topic |
Author |
Message |
tamara Smarty n00b
Joined: 20 May 2016 Posts: 4
|
Posted: Fri May 20, 2016 10:26 am Post subject: How to change number of repetitions of the foreach loop? |
|
|
Hi, I use smarty code and I have to change some parts. I have:
Code: | {foreach from=$llc item=i} |
This loop write 4 lines of text. How to change number of repetitions of the loop?
I can not see in code what is $llc and what is i? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri May 20, 2016 1:42 pm Post subject: |
|
|
Use the documented syntax.
Code: | {foreach $array as $var}{if $var@first}------+-------+----------
iter | key | value...
------+-------+----------
{/if} {$var@iteration|string_format:%4d} | {$var@key|string_format:%-5s} | {$var}
{if $var@last}------+-------+----------{/if}
{/foreach} |
|
|
Back to top |
|
tamara Smarty n00b
Joined: 20 May 2016 Posts: 4
|
Posted: Fri May 20, 2016 4:47 pm Post subject: |
|
|
Sorry, I am new in smarty, I did not solve the problem. More help pls.
for example: How to re loop twice instead of 4 times? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri May 20, 2016 5:08 pm Post subject: |
|
|
Read the documentation and read the example I provided.
Then answer question yourself. |
|
Back to top |
|
tamara Smarty n00b
Joined: 20 May 2016 Posts: 4
|
Posted: Sat May 21, 2016 7:17 am Post subject: |
|
|
I found the php/mysql query where is limit 4 and this is way to resolve.
Thank you for the wrong information, the answer is not in smarty documentation! |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat May 21, 2016 1:27 pm Post subject: |
|
|
You asked a question on Smarty forum. Why would I think about MySQL?
How should I know that MySQL is involved at all, in first place? |
|
Back to top |
|
tamara Smarty n00b
Joined: 20 May 2016 Posts: 4
|
Posted: Sat May 21, 2016 3:23 pm Post subject: |
|
|
In the background of this smarty foreach function is the array and smarty shows all the variable.
I thought there are people who know smarty. Documentation is nonsense. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat May 21, 2016 7:11 pm Post subject: |
|
|
tamara wrote: | Documentation is nonsense. |
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue May 24, 2016 5:21 pm Post subject: |
|
|
AnrDaemon
Answers like this are not helpfull at all and are not good for the quality the the forum.
Code: | {foreach $foo as $bar}
{$bar}
{if $bar@iteration == 2}{break}{/if}
{/foreach}
|
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue May 24, 2016 10:10 pm Post subject: |
|
|
U.Tews wrote: | AnrDaemon
Answers like this are not helpfull |
Replies "documentation is a nonsense" are more helpful, of course. |
|
Back to top |
|
|