XF 2.0 Foreach 'count' attribute

Valhalla

Well-known member
Is it not possible to use the count attribute in foreach loops within templates in XF 2?

It's used in approval_queue template.
 
I was suggesting it might be used redundantly in this template.

In my testing, I wasn’t able to get this to work (where it had worked in XF 1).
 
I agree that the count attribute appears to be broken.
I just reviewed the code in Template/Compiler/Tag/Foreach.php and it is meant to work, but I can't get any life out of it.
Will file a bug in a moment.

Funnily enough, the first use of foreach in the conversation_list_macros template also uses an "if" expression to limit the matches. My PHP skills aren't good enough for me to figure out how the "if" works though - it certainly isn't explicitly handled in the Foreach.php code. (Ironically, the use of the expression in that particular template is redundant anyway :D)
 
I agree that the count attribute appears to be broken.
I just reviewed the code in Template/Compiler/Tag/Foreach.php and it is meant to work, but I can't get any life out of it.
Will file a bug in a moment.

Funnily enough, the first use of foreach in the conversation_list_macros template also uses an "if" expression to limit the matches. My PHP skills aren't good enough for me to figure out how the "if" works though - it certainly isn't explicitly handled in the Foreach.php code. (Ironically, the use of the expression in that particular template is redundant anyway :D)
OMFG. OK, I was reviewing the code in the wrong tree :sick: ... oh dear!
Turns out the code under .../library is the old XF1 stuff, and the code under .../src is XF2 🤣

So, the updated story is that the count attribute is just plain gone from foreach in XF2.
Incidentally, I can now see how the "if" attribute is handled in Template/Compiler/Tag/ForeachTag.php ;)
 
Top Bottom