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

    I need to figure out how to display a list of news, on an information-monitor. (like in airports etc)

    So I have 3 divs, 3 boxes, where I want the news to be displayed. And then I want each box to fade in and out when it switches to the next piece of news. (Say, I have 9 pieces of news, and want to display them on 3 boxes, one at a time)

    The question is how to do that best.

    I don’t want the same piece of news displayed twice on the screen, ie. in box 1 and 3 etc. So using random is out, as the amount of news won’t be far above 10. So the odds are too big.

    I’m thinking that if I make 3 ditto calls, and then if I can make ditto call 1 display news 1, 4 and 7, and ditto call 2 display 2, 5 and 8, and ditto call 3 display 3, 6 and 9 - then it should work fine.

    However... how can I accomplish this? Or am I missing a much simpler way of doing it? I could make 3 containers, but this will require my users to judge which container to put the document in. I’d like it if they don’t have to worry about that.

    This may have appeared confusing... let me know if you need any clarification. Thankyou in advance.
      • 7231
      • 4,205 Posts
      Create a snippet that returns an array of the last 10 news articles. Then you can set up the snippet to output news the way you describe bellow but simply having a switch statement that return the IDs for the news. You then use an input parameter to determine which statement will be returned. Hope this makes sense.

      You would use it something like this:
      [!Ditto? &documents=`[[returnNewsDocs? &state=`1`]]` &tpl=`...`!]
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 10449
        • 956 Posts
        As always with MODx, there’s several ways to swing a cat... you could try using the start parameter (i.e. offset): http://ditto.modxcms.com/files/snippet-ditto-php.html#start

        [!Ditto? &start=`0` &display=`3`!]
        [!Ditto? &start=`3` &display=`3`!]
        [!Ditto? &start=`6` &display=`3`!]

          • 28451
          • 46 Posts
          Thankyou Ganesh, that’s a good way to swing a cat wink Hadn’t seen that parameter, thanks a lot.