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

    I have a resources structure like this :
    Year 2014
    - Jeudi 26 Juin
    - Vendredi 27 Juin
    - Samedi 28 Juin
    - Dimanche 29 Juin
    


    The number of days can change depending of the years...

    I need to produce this kind of code :

    <button class="button" data-filter=".day-1">Jeudi 26 Juin</button>
    <button class="button" data-filter=".day-2">Vendredi 27 Juin</button>
    <button class="button" data-filter=".day-3">Samedi 28 Juin</button>
    <button class="button" data-filter=".day-4">Dimanche 29 Juin</button>


    My problem is how to automatically get the iteration for "day-1", "day-2"...

    Any idea ?

    This question has been answered by BobRay. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      You can't iterate over getResources' results because what it returns is a single, large string of text.

      You might still be able to do what you want with getResources, though, if you can sort the results so they end up in the correct order (by, say, the createdon field). You can then use getResources' +idx placeholder to put in the day number:

      <button class="button" data-filter=".day-[[+idx]]">[[+pagetitle]]</button>
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 28173
        • 409 Posts
        I didn't know the placeholder [[+idx]]
        Thanks a lot, it's working like a charm ! [ed. note: Spheerys last edited this post 9 years, 6 months ago.]
          • 3749
          • 24,544 Posts
          Glad I could help. Thanks for reporting back. smiley
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting