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

    Hope everyones doing great.

    Been scratching my head a little. Currently have over 50 FireFox tabs open looking through various posts and I can’t seem to find a similar post to the situation I’am currently in, so I thought I’d quickly make a post.

    Working on a website that provides Poker players with a game schedule/upcoming events breakdown.

    (Game Schedule Example)

    -> Game Schedule (MODx Container)

    --> Mondays (Styled as a header / MODx Container)
    ---> 1:30PM | Free Roll (Resource)
    ---> 3:00PM | Free Roll (Resource)

    --> Tuesdays (Styled as a header / MODx Container)
    ---> 1:30PM | Free Roll (Resource)
    ---> 3:00PM | Free Roll (Resource)

    --> Wednesdays (Styled as a header / MODx Container)
    ---> And so on, and so on..

    Would I be able to pull all the containers and contents using one ditto call and have it displayed somewhat similar to the example above? Using Ditto, would I be able to display the events for Monday before Tuesday and that days events?

    Reason for trying to use a single Ditto call is that if the client decided to add another day, theres no need to add in another Ditto call.

    Also, is there any way of creating a Ditto template which would style the parent container name differently to the children?

    Any help much appreciated. If theres a better way of going about my game schedule, I’am all ears.

    Thanks again everyone,
    - Marcin
      • 1122
      • 209 Posts
      Hi,
      tasks of this kind are easily solveable with a single (but recursive) call of Ditto -- you need to carefully build your main call of Ditto and all remaining calls (nested) go automated from within template of that first (main) call.

      Scheme for your task (suppose that Game Schedule container is an id=10):
      main call (list all weekdays):
      [[Ditto? &parents=`10` &depth=`1` &display=`all` &tpl=`day-header` &sortBy=`<a-clause-to-sort-days>` &sortDir=`...`]]
      
      sample template for main call (chunk "day-header"):
      <!-- display header --!>
      <h3>[+pagetitle+]</h3>
      <!-- list all games of this day via nested Ditto call --!>
      [[Ditto? &parents=`[+id+]` &depth=`1` &display=`all` &tpl=`game-layout` &sortBy=`<a-clause-to-sort-games>` &sortDir=`...`]]
      
      sample template for nested call (chunk "game-layout"):
      <!-- display single game --!>
      <h4>[+pagetitle+]</h4>
      <div class="...">[+someTV+]</div>
      etc. etc.
      

      You only need to build/add proper sort clauses in order to achieve desired order of weekdays (and games within specific weekday).
        • 18246
        • 8 Posts
        Awesome alik!

        I didn’t realise you could call ditto in chunks like that.

        Awesome awesome, thanks for the help! Now to tweak some more. smiley
          • 23571
          • 223 Posts
          Wow, I definitely learned something new on that one. Thanks!