We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32963
    • 1,732 Posts
    Hello everyone,

    The new parser (GreenToken) will support passing arrays to a snippet/widget in the following proposed format:

    This will pass in $names as an index array
    [[Widget? &names[]=`mary` &names[]=`James`]]

    This will pass in $colors as an associate array
    [[Widget? &colors[red]=`#ff0000` &colors[blue]=`#0000ff`]]

    The format might change slightly but what do you think about the idea of being able to pass arrays to a snippet. Think it will ever come in handy?

      xWisdom
      www.xwisdomhtml.com
      The fear of the Lord is the beginning of wisdom:
      MODx Co-Founder - Create and do more with less.
      • 6726
      • 7,075 Posts
      The more I read your post about the new parser, the more I think I am going to like it a lot laugh

      I don’t fully grasp what it means yet, but I am pretty interrested !
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 32241
        • 1,495 Posts
        Raymond, I think the second example will need 2 input, the one for the key and the other one for the value, maybe something like this will work.
        [[Widget? &colors[red]=`#ff0000` &colors[blue]=`#0000ff`]]
        


        If you leave it empty it, will quto populate the key with auto-increment integer number, just like the way PHP do its array processing.
          Wendy Novianto
          [font=Verdana]PT DJAMOER Technology Media
          [font=Verdana]Xituz Media
          • 32963
          • 1,732 Posts
          Quote from: Djamoer at Feb 15, 2006, 10:12 AM

          Raymond, I think the second example will need 2 input, the one for the key and the other one for the value, maybe something like this will work.
          [[Widget? &colors[red]=`#ff0000` &colors[blue]=`#0000ff`]]
          


          You’re correct.
          I had it like that in the post but SMF converted it into colors smiley

            xWisdom
            www.xwisdomhtml.com
            The fear of the Lord is the beginning of wisdom:
            MODx Co-Founder - Create and do more with less.
            • 32241
            • 1,495 Posts
            Quote from: xwisdom at Feb 15, 2006, 02:04 PM

            You’re correct.
            I had it like that in the post but SMF converted it into colors smiley

            Than it’s SMF that has to be blamed then smiley Pardon all the typo in my previous post, for some reason I didn’t double check my post.
              Wendy Novianto
              [font=Verdana]PT DJAMOER Technology Media
              [font=Verdana]Xituz Media