AnsweredAssumed Answered

iterate a collection in WCMQS

Question asked by michaelc on Jul 29, 2013
Latest reply on Jul 30, 2013 by michaelc
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 ?

Outcomes