2 Replies Latest reply: Nov 5, 2014 10:00 PM by Liam Dilley RSS

    Looping and storing into arrays

    Liam Dilley CommunityMVP

      Anyone managed this yet, or BC team - you got any thoughts....?

       

      There could be cases and situations like this one and in this case either a solution or just having a loop array filter would be nice also...

       

      Issue:

      You have a web app with classifications. You want to people in a company. You want to show board members (Classification) in one section and the rest of the team in another.

      The Rest of the team will show the board members because you do not have classifications in list view.

       

      Solution 1:

      BC to provide classifications in list view liquid/collection

       

      Solution 2: (And something we probably may need too)

      It would be great to loop through a collection and store into an array

       

      {% assign myarray = [] -%}

      {module_webapp collection="myitems"}

      {% for item in myitems-%}

           {% myarray | map: item.name-%}

      {% endfor -%}

       

      {{myarray}}

       

      It would be handy to be able to store items in an array. You can already map an array, have a manually made array you can loop through, have a string you map into an array via a cookie etc.

        • 1. Re: Looping and storing into arrays
          Robert Bell (Bosweb) Community Member

          Those would be great.

           

          What I'd really like to see, is basic filters on module_ tags, so we can reduce the set of returned elements before the infernal pagination limit is hit. (Wasn't this already mentioned somewhere?)

           

          E.g., in your example, only the first x hundred webapp items can be looped over to test for classification/name/whatever. We should instead be able to say something like {module_webapp collection="myitems" where="item.classificationName EQ foobar"}, so we'll get matching items even though they wouldn't have appeared in the first page of unfiltered results.

          • 2. Re: Looping and storing into arrays
            Liam Dilley CommunityMVP

            Well Rob, you have {module_data... So if you want to go even further You can turn to that and you can defiantly do the where. I think bringing that to all modules would be some serious overkill work, you would be basically replicating that functionality.

            That is how I am classing _data - This is your hardcore module to use when you want to do some serious s*** but as I have said in other threads, We should not be turning to that all the time when we just need something like categories in list view. That would also be over kill in those situations.

             

            But then when you do use _data it would be good to get some results, map it to an array and then use that for something else.