<?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 do I get the multifield count in a component AEM? in Adobe Experience Manager Questions</title>
    <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-do-i-get-the-multifield-count-in-a-component-aem/m-p/458076#M131938</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;LI-USER uid="17458627"&gt;&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You already might be using a model to get the multi data, that multi is returned as a list which you can iterate in HTL.&lt;BR /&gt;&lt;BR /&gt;Since, your backend code&amp;nbsp;&lt;A href="https://sling.apache.org/apidocs/sling11/org/apache/sling/api/resource/Resource.html#listChildren--" target="_blank" rel="nofollow noopener noreferrer"&gt;Resource#listChildren&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;will return an&amp;nbsp;&lt;/SPAN&gt;Iterator&amp;lt;Resource&amp;gt;&lt;SPAN&gt;, you will not be able to get the size of the list of children from there.&lt;BR /&gt;&lt;BR /&gt;Either you can , make use of current item properties :&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;// iterate and check if thats the last item, if yes -&amp;gt; return the count&lt;BR /&gt;&amp;lt;sly data-sly-list.demo=“${demo123.items.listChildren}”&amp;gt; 
    &amp;lt;sly data-sly-test=“${demoList.last}”&amp;gt;  
     ${demoList.count}
&amp;lt;/sly&amp;gt;&lt;/PRE&gt;&lt;P&gt;Or you can declare a variable for itemList and use .length :&lt;/P&gt;&lt;PRE&gt;&amp;lt;sly data-sly-list.item="resource.listChildren"&amp;gt;
    &amp;lt;sly data-sly-list.itemList="item.listChildren"&amp;gt;
        ${itemList.length} 
    &amp;lt;/sly&amp;gt;
&amp;lt;/sly&amp;gt;&lt;/PRE&gt;&lt;P&gt;Hope this helps!&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;/P&gt;&lt;P&gt;Milind&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jun 2022 11:53:25 GMT</pubDate>
    <dc:creator>milind_bachani</dc:creator>
    <dc:date>2022-06-27T11:53:25Z</dc:date>
    <item>
      <title>How do I get the multifield count in a component AEM?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-do-i-get-the-multifield-count-in-a-component-aem/m-p/458071#M131935</link>
      <description>&lt;P&gt;Actually, I need to get the multifield count in the component, and then I need to use that count in the HTL. Is there any way to get the multifield count?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 11:23:59 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-do-i-get-the-multifield-count-in-a-component-aem/m-p/458071#M131935</guid>
      <dc:creator>Ameen_Dev</dc:creator>
      <dc:date>2022-06-27T11:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get the multifield count in a component AEM?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-do-i-get-the-multifield-count-in-a-component-aem/m-p/458076#M131938</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;LI-USER uid="17458627"&gt;&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You already might be using a model to get the multi data, that multi is returned as a list which you can iterate in HTL.&lt;BR /&gt;&lt;BR /&gt;Since, your backend code&amp;nbsp;&lt;A href="https://sling.apache.org/apidocs/sling11/org/apache/sling/api/resource/Resource.html#listChildren--" target="_blank" rel="nofollow noopener noreferrer"&gt;Resource#listChildren&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;will return an&amp;nbsp;&lt;/SPAN&gt;Iterator&amp;lt;Resource&amp;gt;&lt;SPAN&gt;, you will not be able to get the size of the list of children from there.&lt;BR /&gt;&lt;BR /&gt;Either you can , make use of current item properties :&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;// iterate and check if thats the last item, if yes -&amp;gt; return the count&lt;BR /&gt;&amp;lt;sly data-sly-list.demo=“${demo123.items.listChildren}”&amp;gt; 
    &amp;lt;sly data-sly-test=“${demoList.last}”&amp;gt;  
     ${demoList.count}
&amp;lt;/sly&amp;gt;&lt;/PRE&gt;&lt;P&gt;Or you can declare a variable for itemList and use .length :&lt;/P&gt;&lt;PRE&gt;&amp;lt;sly data-sly-list.item="resource.listChildren"&amp;gt;
    &amp;lt;sly data-sly-list.itemList="item.listChildren"&amp;gt;
        ${itemList.length} 
    &amp;lt;/sly&amp;gt;
&amp;lt;/sly&amp;gt;&lt;/PRE&gt;&lt;P&gt;Hope this helps!&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;/P&gt;&lt;P&gt;Milind&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 11:53:25 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-do-i-get-the-multifield-count-in-a-component-aem/m-p/458076#M131938</guid>
      <dc:creator>milind_bachani</dc:creator>
      <dc:date>2022-06-27T11:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get the multifield count in a component AEM?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-do-i-get-the-multifield-count-in-a-component-aem/m-p/458134#M131965</link>
      <description>&lt;P&gt;&lt;LI-USER uid="17458627"&gt;&lt;/LI-USER&gt;&amp;nbsp;HTL does not offer a way to get the list size either, however it allows getting&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#226-list" target="_blank" rel="nofollow noopener noreferrer"&gt;interesting properties of the current item&lt;/A&gt;:&lt;/P&gt;&lt;PRE&gt;* index: zero-based &lt;SPAN class=""&gt;counter&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;SPAN class=""&gt;0.&lt;/SPAN&gt;.length-&lt;SPAN class=""&gt;1&lt;/SPAN&gt;)&lt;/SPAN&gt;;
* count: one-based &lt;SPAN class=""&gt;counter&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;SPAN class=""&gt;1.&lt;/SPAN&gt;.length)&lt;/SPAN&gt;;
* first: &lt;SPAN class=""&gt;true&lt;/SPAN&gt; &lt;SPAN class=""&gt;for&lt;/SPAN&gt; the first element being iterated;
* middle: &lt;SPAN class=""&gt;true&lt;/SPAN&gt; &lt;SPAN class=""&gt;if&lt;/SPAN&gt; element being iterated is neither the first nor the last;
* last: &lt;SPAN class=""&gt;true&lt;/SPAN&gt; &lt;SPAN class=""&gt;for&lt;/SPAN&gt; the last element being iterated;
* odd: &lt;SPAN class=""&gt;true&lt;/SPAN&gt; &lt;SPAN class=""&gt;if&lt;/SPAN&gt; count is odd;
* even: &lt;SPAN class=""&gt;true&lt;/SPAN&gt; &lt;SPAN class=""&gt;if&lt;/SPAN&gt; count is even.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g. If you want to display the whole list count&lt;/P&gt;&lt;PRE&gt;&amp;lt;sly data-sly-test.totalItems=&lt;SPAN class=""&gt;"${0}"&lt;/SPAN&gt;&amp;gt;&amp;lt;/sly&amp;gt;
&amp;lt;sly data-sly-list.child=&lt;SPAN class=""&gt;"${resource.listChildren}"&lt;/SPAN&gt;&amp;gt;
    &amp;lt;sly data-sly-test.totalItems=&lt;SPAN class=""&gt;"${ childList.count }"&lt;/SPAN&gt;&amp;gt;&amp;lt;/sly&amp;gt;
&amp;lt;/sly&amp;gt;&lt;/PRE&gt;&lt;P&gt;${ totalItems }&lt;SPAN&gt;&amp;nbsp;- this will give you the number of items in the list.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 15:28:14 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-do-i-get-the-multifield-count-in-a-component-aem/m-p/458134#M131965</guid>
      <dc:creator>shaileshbassi</dc:creator>
      <dc:date>2022-06-27T15:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get the multifield count in a component AEM?</title>
      <link>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-do-i-get-the-multifield-count-in-a-component-aem/m-p/458619#M132126</link>
      <description>&lt;P&gt;Thanks for your solution. It worked as expected.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 12:47:44 GMT</pubDate>
      <guid>https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-do-i-get-the-multifield-count-in-a-component-aem/m-p/458619#M132126</guid>
      <dc:creator>Ameen_Dev</dc:creator>
      <dc:date>2022-06-29T12:47:44Z</dc:date>
    </item>
  </channel>
</rss>

