We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10386
    • 42 Posts
    Hi, I am quite new to ModX, and i started templating today:
    1/
    I am trying to get the loop index of ditto, like the loop.index in jinja, is there something similar?

    2/
    can i test a variable :
    if ( [+descriptionItem+] != null) { do something }
      • 16278
      • 928 Posts
      Assuming we are talking about MODx Evo (if you have installed Revo, forget Ditto, look at getResources instead:

      1) Ditto’s index variable appears as the placeholder [+ditto_iteration+]

      2) Yes. Ditto has a built-in copy of PHx ("placeholders extended"), which includes the opportunity to conditionally modify the output of placeholders. There’s good documentation for it in the old Wiki.

      smiley KP
        • 10386
        • 42 Posts
        Thanks!