We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32098
    • 31 Posts
    I want to use getResources to create a table of child resources and in the first column I need to numerate each returned row incrementally beginning from 1. What’s the easiest way to do this?

    I know I can call getResources from within a snippet like so:

        $output = $modx->runSnippet('getResources', array('parents' => 9, 'tpl' => 'listchunk', 'processTVs => '1', 'tvPrefix => ''));


    but what do I have to add to that to get a number to feed to the relevant placeholder in the chunk?

    Thanks.
      • 28215
      • 4,149 Posts
      In your chunk use the idx placeholder:

      <li>[[+idx]]. [[+pagetitle]]</li>
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 32098
        • 31 Posts
        Brilliant, thanks. Actually, I went back to the documentation and noticed the idx parameter and was in the process of trying it. It works. No need even for an extra bit of snippet. getResources does it on its own. Sometimes - very occasionally - life just seems so wonderfully simple.