CMS Development

simonp
メンバー

Scope of variable in for loop

解決

I am trying to number of images created by a module as define by loop.length value

 

i trying th following:

 

<div id="a">
    {% for item in module.image_gallery %}
              {% set no_Images = loop.length %}
             <img src="{{ item.src }}" alt="{{ item.alt }}" >

              <h3>Loop length with loop = {{ no_Images }}</h3>
     {% endfor %} 

</div>

<h3>Loop length  outside of loop= {{ no_Images }}</h3>

 

But i dont seem to be able to get the value outide of the loop

 

for now i using jquery to find the length;

var imgCount = $("img").length;

0 いいね!
1件の承認済みベストアンサー
John
解決策
トップ投稿者 | Platinum Partner
トップ投稿者 | Platinum Partner

Scope of variable in for loop

解決

try:

Loop length outside of loop {{ module.image_gallery|length }}


I like kudos almost as much as cake – a close second.

元の投稿で解決策を見る

2件の返信
John
解決策
トップ投稿者 | Platinum Partner
トップ投稿者 | Platinum Partner

Scope of variable in for loop

解決

try:

Loop length outside of loop {{ module.image_gallery|length }}


I like kudos almost as much as cake – a close second.

simonp
メンバー

Scope of variable in for loop

解決

thankls john

0 いいね!