tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/14670-increment-integer-on-loopCascade CMS: Discussion 2016-10-02T02:45:21Ztag:help-archives.hannonhill.com,2010-02-09:Comment/406052132016-08-24T19:20:17Z2016-08-24T19:20:17ZIncrement integer on loop<div><p>Hi Matthew,</p>
<p>Loops actually have an existing iterator that can be accessed
using <code>$foreach.index</code>. For additional information about
available properties within loops, see <a href="http://www.hannonhill.com/kb/Script-Formats/#engine_improvements">this
page</a>.</p>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/406052132016-08-24T19:26:23Z2016-08-24T19:26:23ZIncrement integer on loop<div><p>oh that's amazing! is there anyway to make the iterator start at
1 rather than 0?</p></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/406052132016-08-24T20:43:10Z2016-08-24T20:43:10ZIncrement integer on loop<div><p>Hi Matthew,</p>
<p>You would have to implement something similar to what you were
doing and add one to the iterator:</p>
<pre>
<code>#set ($videos = $_XPathTool.selectNodes($contentRoot, "/system-data-structure/featured-videos/video"))
#foreach($video in $videos)
<div role="tabpanel" class="tab-pane active" id="youtube-${_MathTool.add($foreach.index, 1)}">
</div>
#end</code>
</pre>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffith