Sean Kendle
Member
Summary: How do I perform simple addition in a template?
Hi, Brogan. I'm trying to insert an ad between X threads in my forum in the threads list page.
I created a template modification for thread_list, and with the help of another post wrote this code:
I just spent about half an hour searching google and this site, and I can't figure out any way to add 1 to a number within a template. (Or, add two variables together within a template, generally speaking, because I assume I'll need to do that again later.)
I have created a new variable, but would like to simply add 1 to that variable for each "sticky" and "normal" thread, since the variable $i resets for the second FOR loop, and I want to treat Sticky threads the same as normal Threads as far as inserting an ad below them.
I've tried the bold lines above for creating an adding a variable, but trying to do this results in concatenating a string, rather than adding 1 to the number.
Can you please help me with this?
Hi, Brogan. I'm trying to insert an ad between X threads in my forum in the threads list page.
I created a template modification for thread_list, and with the help of another post wrote this code:
Code:
<xen:set var="$threadPosition">0</xen:set>
<xen:foreach loop="$stickyThreads" value="$thread" i="$i">
<xen:include template="thread_list_item" />
<xen:set var="$threadPosition">$threadPosition + 1</xen:set>
</xen:foreach>
</xen:hook>
<xen:include template="ad_thread_list_below_stickies" />
<xen:foreach loop="$threads" value="$thread" i="$i">
<xen:include template="thread_list_item" />
<!-- insert Ads every N threads: -->
<xen:if is="{$i} == 3">
<xen:include template="ads_in_content_1" />
<xen:include template="ads_mobile_in_content_1" />
</xen:if>
<xen:if is="{$i} == 10">
<xen:include template="ads_in_content_2" />
<xen:include template="ads_mobile_in_content_2" />
</xen:if>
<!-- THREAD POSITION TEST: {$i} -->
</xen:foreach>
I just spent about half an hour searching google and this site, and I can't figure out any way to add 1 to a number within a template. (Or, add two variables together within a template, generally speaking, because I assume I'll need to do that again later.)
I have created a new variable, but would like to simply add 1 to that variable for each "sticky" and "normal" thread, since the variable $i resets for the second FOR loop, and I want to treat Sticky threads the same as normal Threads as far as inserting an ad below them.
I've tried the bold lines above for creating an adding a variable, but trying to do this results in concatenating a string, rather than adding 1 to the number.
Can you please help me with this?