Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

How to change number of repetitions of the foreach loop?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
tamara
Smarty n00b


Joined: 20 May 2016
Posts: 4

PostPosted: Fri May 20, 2016 10:26 am    Post subject: How to change number of repetitions of the foreach loop? Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri May 20, 2016 1:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
tamara
Smarty n00b


Joined: 20 May 2016
Posts: 4

PostPosted: Fri May 20, 2016 4:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri May 20, 2016 5:08 pm    Post subject: Reply with quote

Read the documentation and read the example I provided.
Then answer question yourself.
Back to top
View user's profile Send private message
tamara
Smarty n00b


Joined: 20 May 2016
Posts: 4

PostPosted: Sat May 21, 2016 7:17 am    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat May 21, 2016 1:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
tamara
Smarty n00b


Joined: 20 May 2016
Posts: 4

PostPosted: Sat May 21, 2016 3:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat May 21, 2016 7:11 pm    Post subject: Reply with quote

tamara wrote:
Documentation is nonsense.

Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue May 24, 2016 5:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue May 24, 2016 10:10 pm    Post subject: Reply with quote

U.Tews wrote:
AnrDaemon
Answers like this are not helpfull

Replies "documentation is a nonsense" are more helpful, of course.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP