<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to respect index in a for loop in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/How-to-respect-index-in-a-for-loop/m-p/215574#M9520</link>
    <description>&lt;P&gt;instead of looping to your title and detail repeater. try grouping this two fields together and make it a repeater group.&lt;BR /&gt;ex: {{ table_row }}&lt;/P&gt;&lt;PRE&gt; &amp;lt;tbody&amp;gt;
      {% for row in  module.detailgroup.&lt;SPAN&gt;table_row&amp;nbsp;&lt;/SPAN&gt;%}
        &amp;lt;tr&amp;gt;
          &amp;lt;td&amp;gt;
            {{ row.titledata }}
          &amp;lt;/td&amp;gt;
          &amp;lt;td&amp;gt;
            {{ row.detaildata }}
          &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;  
        {% endfor %}
      &amp;lt;/tbody&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;you don't need the titledata&amp;nbsp;and detaildata to be a repeater.&lt;BR /&gt;&lt;BR /&gt;the problem if you have max-out your nested group.&lt;BR /&gt;&lt;BR /&gt;best of luck,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Nov 2018 04:04:33 GMT</pubDate>
    <dc:creator>valerajoey</dc:creator>
    <dc:date>2018-11-08T04:04:33Z</dc:date>
    <item>
      <title>How to respect index in a for loop</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-respect-index-in-a-for-loop/m-p/215115#M9467</link>
      <description>&lt;P&gt;I'm trying to make a table that for loops through repeating fields.&lt;/P&gt;&lt;P&gt;I've managed to get the for loop working:&lt;/P&gt;&lt;PRE&gt;      &amp;lt;tbody&amp;gt;
      {% for title in module.detailgroup.titledata %}
      {% for detail in module.detailgroup.detaildata %}
        &amp;lt;tr&amp;gt;
          &amp;lt;td data-title="{{ module.headergroup.titlecolumnheader }}"&amp;gt;
            {{ title }}
          &amp;lt;/td&amp;gt;
          &amp;lt;td data-title="{{ module.headergroup.detailcolumnheader }}"&amp;gt;
            {{ detail }}
          &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;  
        {% endfor %}
        {% endfor %}
      &amp;lt;/tbody&amp;gt;&lt;/PRE&gt;&lt;P&gt;The for loop part works, here is the result:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot from 2018-11-05 16-07-58.png" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/12912i3C630D333F01539A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot from 2018-11-05 16-07-58.png" alt="Screenshot from 2018-11-05 16-07-58.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that I want the table to respect the loop index, i.e.:&lt;/P&gt;&lt;P&gt;Title 1 | Data 1&lt;/P&gt;&lt;P&gt;Title 2 | Data 2&lt;/P&gt;&lt;P&gt;I think I need to add an if statement that incorporates loop.index, but I'm not exactly sure how to do that/if that is the best method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Nov 2018 21:29:29 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-respect-index-in-a-for-loop/m-p/215115#M9467</guid>
      <dc:creator>jdepumpo</dc:creator>
      <dc:date>2018-11-05T21:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to respect index in a for loop</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-respect-index-in-a-for-loop/m-p/215392#M9492</link>
      <description>&lt;P&gt;&amp;nbsp;hey there,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;First I suggest&amp;nbsp; grouping your fields, but based on your code you have a {{ detail }} looping inside your {{ title }}, its a bit confusing which loop.index where you looking for? maybe a bit of explaination.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 03:14:19 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-respect-index-in-a-for-loop/m-p/215392#M9492</guid>
      <dc:creator>valerajoey</dc:creator>
      <dc:date>2018-11-07T03:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to respect index in a for loop</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-respect-index-in-a-for-loop/m-p/215490#M9502</link>
      <description>&lt;P&gt;Sorry, my question was a bit unclear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;      &amp;lt;tbody&amp;gt;
      {% for title in module.detailgroup.titledata %}
      {% for detail in module.detailgroup.detaildata %}
        &amp;lt;tr&amp;gt;
          &amp;lt;td&amp;gt;
            {{ title }}
          &amp;lt;/td&amp;gt;
          &amp;lt;td&amp;gt;
            {{ detail }}
          &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;  
        {% endfor %}
        {% endfor %}
      &amp;lt;/tbody&amp;gt;&lt;/PRE&gt;&lt;P&gt;Right now I am looping through the respective fields of titledata and detaildata. It loops through all of the fields, but does not respect the index.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Preview.PNG" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/12942iD79292D47538644E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Preview.PNG" alt="Preview.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;My desired result&amp;nbsp;is to have the loop.index match the table row number. In other words, the loop index of Title1 and Detail1 are both 1, so they should be displayed in row 1, like so:&lt;/P&gt;&lt;PRE&gt;(Row 1) Title 1 | Detail 1
(Row 2) Title 2 | Detail 2
etc..&lt;/PRE&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 17:16:34 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-respect-index-in-a-for-loop/m-p/215490#M9502</guid>
      <dc:creator>jdepumpo</dc:creator>
      <dc:date>2018-11-07T17:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to respect index in a for loop</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-respect-index-in-a-for-loop/m-p/215574#M9520</link>
      <description>&lt;P&gt;instead of looping to your title and detail repeater. try grouping this two fields together and make it a repeater group.&lt;BR /&gt;ex: {{ table_row }}&lt;/P&gt;&lt;PRE&gt; &amp;lt;tbody&amp;gt;
      {% for row in  module.detailgroup.&lt;SPAN&gt;table_row&amp;nbsp;&lt;/SPAN&gt;%}
        &amp;lt;tr&amp;gt;
          &amp;lt;td&amp;gt;
            {{ row.titledata }}
          &amp;lt;/td&amp;gt;
          &amp;lt;td&amp;gt;
            {{ row.detaildata }}
          &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;  
        {% endfor %}
      &amp;lt;/tbody&amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;you don't need the titledata&amp;nbsp;and detaildata to be a repeater.&lt;BR /&gt;&lt;BR /&gt;the problem if you have max-out your nested group.&lt;BR /&gt;&lt;BR /&gt;best of luck,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 04:04:33 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-respect-index-in-a-for-loop/m-p/215574#M9520</guid>
      <dc:creator>valerajoey</dc:creator>
      <dc:date>2018-11-08T04:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to respect index in a for loop</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-respect-index-in-a-for-loop/m-p/215837#M9569</link>
      <description>&lt;P&gt;Brilliant!&lt;/P&gt;&lt;P&gt;I didn't realize you could set groups as repeaters too. Thanks so much!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2018 14:16:44 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-respect-index-in-a-for-loop/m-p/215837#M9569</guid>
      <dc:creator>jdepumpo</dc:creator>
      <dc:date>2018-11-09T14:16:44Z</dc:date>
    </item>
  </channel>
</rss>

