XF 2.2 Foreach $threads loop question.

Sivoph

Member
Good afternoon, developers. I'm appending a created element to a div container and using Jquery + innerHTML to append the foreach loop of most recent threads. I'm trying to get the loop to display the 1st, 2nd, 3rd (...and so forth) newest thread through each iteration. Thus I am focused in on one piece of template code in particular:

<xf:foreach loop="$threads" value="$thread">
<xf:macro template="thread_list_macros" name="item"
arg-thread="{$thread}" />
</xf:foreach>

The output is currently the structItem div in the structItemContainer (set to display only one newest thread).

I'm not a coder, just have some basic HTML experience. Now, others in this forum have commented on the use of $i and {{rand(1,5)}}. Is this possible simply amending the code with either of these? If so, how would I format it? Something like this, I was thinking:

<xf:foreach loop="{{rand(1,5) , {$threads}}}" value="$thread">
<xf:macro template="thread_list_macros" name="item"
arg-thread="{$thread}" />
</xf:foreach>

Ignoring the jquery function altogether, how would I get the foreach template code to display a new threads through each iteration? Right now it just displays the same thread post (newest) through each iteration. Is this possible without PHP and preferably without having global implications. So maybe using xf:set or a conditional.


Thank you for any help on this.
 
Last edited:
Top Bottom