cancel
Showing results for 
Search instead for 
Did you mean: 

iterate a collection in WCMQS

michaelc
Champ on-the-rise
Champ on-the-rise
So I have a need in the JavaScript layer to pull a value from a collection and then split it.

Problem is I can't seem to figure out how to iterate the collection itself.

at the Freemarker level I do the following.

   <#list articles.assets as article>   
         <li><a href="<@makeurl asset=article force='long'/>">${article.title!article.name}</a></li>
         <#assign desc = article.properties["cm:description"]>
         ${desc}                            
   </#list>

So I would expect at the javascript level I could.

      model.articles = collectionService.getCollection(model.section.id, args.collection);
      var colItr = model.articles.assets.iterator();
      while(itr.hasNext() ) {
         itemArray.push("x");
         itemObj = itr.next();
         var itemRow = new Object();
         itemRow.region = itemObj.properties['cm:name'];
         itemRow.description = itemObj.properties['cm:description'];
         itemArray.push("c");
      }
      model.items = itemArray;


but this does not give me any result.
So how do I iterate a wcmqs collection ?
1 REPLY 1

michaelc
Champ on-the-rise
Champ on-the-rise
Ignore me I am an idiot. use the correct iterator.