We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39159
    • 23 Posts
    This is going to be difficult for me to describe, but here's what I'm after.

    I've created a TV in modx called AnchVar. Input type = Text.

    Here's the kind of data I will be entering into this TV

    Textstring1||Textstring2||Textstring3||Textstring4||Textstring5

    Now here's what I don't know how to do... I understand how to output delimited text (output type = delimiter, set whatever delimiter I wish), but what I want is for Modx to randomly output ONE of those text strings... so if I'm running this uncached my page will show one time


    Textstring1

    and the next time maybe

    Textstring5

    I want ONE of the text strings I enter in the Text TV randomly selected and outputted (can I say that?).

    Can anyone give me a pointer in the direction of how I would go about doing this?

    I was thinking getResources, but I could only ever get it to output the entire string, not one of the delimited strings.

    Please help!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Use MIGx. its default output snippet, getImageList, can display random items.
        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
        • 39159
        • 23 Posts
        I came across get image list but was under the impression it only output images but I will give it a second look.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          It is the provided listing snippet for MIGx. There are a lot of naming conventions in MIGx that are holdovers from its original purpose. Basically what it does is parse the MIGx JSON strings and put the individual items into placeholders so you can use them in a tpl like any other listing snippet (Wayfinder, getResources).
            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