Flexible Layout and Query Loop

See this for the loop index: