We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28120
    • 380 Posts
    I've got a list of variables stored in MIGX. They're promo lines like

    "Buy one get one free"
    "Buy before Saturday"
    "It's raining"
    "etc"

    On the same page as the MIGX variable I've got a getResources call to show all the children. On each getResources result I want to show a promo line.

    What I'd do outside of MODX (a php site) is


    1. Set a counter to 0
    2. count the number of items in the array of lines
    3. for each new child get the next line in the array
    4. if the line number exceeds the array count reset the counter to 0

    I've tried set/get placeholders and $_SESSION but the item returned is always the last item in the array. I'm calling the snippet !uncached from the getResources tpl

    Should these work or is there some other global variable variable that is persistent across the page?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You should be able to use a getImageList snippet using &randomize=`1` and &limit=`1` in the getResources tpl.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 28120
        • 380 Posts
        Thanks

        Could do.

        But I think the user wants me to pick them out from the MIGX list in order and go back to item 1 when I've got to the end of the MIGX list
          • 28120
          • 380 Posts
          Got this working using $GLOBALS, which keeps a variable alive for repeat calls of the same snippet so that I'm able to keep a count.