Loop through numbered fields

Description

If you have multiple fields or groups of fields that are similar (i.e. "Image 1," "Image 1 Caption," "Image 2," "Image 2 Caption"), you should write your velocity code once to put them into your page instead of repeating yourself for each one. You can do this with a combination of a "foreach" loop, and a "get()" with the name of the field.

Code

${esc.hash}foreach(${esc.dollar}thing in ${esc.dollar}dotcontent.pull("+structureName:EbiblestudyLesson",10,"modDate desc"))
        ${esc.hash}foreach(${esc.dollar}num in [1..3])
                ${esc.hash}set(${esc.dollar}fieldname = "worksheet${esc.dollar}!{num}")
                ${esc.dollar}thing.get(${esc.dollar}fieldname).rawUri
        ${esc.hash}end
${esc.hash}end