We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12508
    • 63 Posts
    Description of Problem:

    I want to make a page for customers and its projects but it is not working the way I'm doing it. Maybe getResources is not the right tool to make multi-level pages. Here's what I want:

    Expected Outcome:

    Page Customers

    • Customer 1
    • - Project A
      - Project B

    • Customer 2
    • - Project A
      - Project B

    • Customer 3
    • - Project A
      - Project B

    What I did:
    I make a getPage call from Page customers to it's childrens:
    <table class="clients">
       [[!getResources?
            &parents=`[[*id]]`
            &depth=`0`
            &tpl=`tpl-CustOverview`
            &sortby=`{"menuindex":"ASC"}`
            &includeTVs=`1`
            &processTVs=`1`
            &includeContent=`1`
            &debug=`1`
        ]]
    </table>
    


    Then in the getResources template, I make a second call for projects inside each customer:

    tpl-CustOverview:

    <tr>
        <td>[[+tv.customerLogo]]</td>
        <td class="client-desc"><h3>[[+pagetitle]]</h3>
            <div class="clientsText">
                [[!getResources?
                    &depth=`1`
                    &tpl=`tpl-CustDetail`
                    &sortby=`{"menuindex":"ASC"}`
                    &includeContent=`1`
                    &debug=`1`
                ]]
            </div>
        </td>
    </tr>
    


    What I get (of course wrong):

    • Customer 1
    • Customer 2
    • Customer 3
    • - Project A
      - Project B
      - Project A
      - Project B
      - Project A
      - Project B
    • Customer 1
    • Customer 2
    • Customer 3
    • - Project A
      - Project B
      - Project A
      - Project B
      - Project A
      - Project B
    • Customer 1
    • Customer 2
    • Customer 3
    • - Project A
      - Project B
      - Project A
      - Project B
      - Project A
      - Project B

    I think the reason of this behavior is that both getResources call are using the same ID
    &parents=`[[*id]]`
    because both are being called from the same resource (I guess).

    Does anybody out there can help me to solve this problem?
    Thank you in advance.


    • MODX Version: MODX Revolution 2.2.5-pl (traditional)
    • PHP Version: 5.3.5
    • Database (MySQL) Version: 5.5.9
    • Additional Server Info: Apache 2.0
    • Installed MODX Add-ons: Babel, Breadcrumbs, getPage, getResources, SimpleSearch, TinyMCE, UltimateParent, Wayfinder
      • 6038
      • 228 Posts
      I'm guessing your resource structure is each client having two projects (A&B) as child resources, but i think you need to pass the current client/parent resource id to the nested snippet. So your chunk should be:
      <tr>
          <td>[[+tv.customerLogo]]</td>
          <td class="client-desc"><h3>[[+pagetitle]]</h3>
              <div class="clientsText">
                  [[!getResources?
                      &parents=`[[+id]]`
                      &depth=`1`
                      &tpl=`tpl-CustDetail`
                      &sortby=`{"menuindex":"ASC"}`
                      &includeContent=`1`
                      &debug=`1`
                  ]]
              </div>
          </td>
      </tr>

      Also, you can remove the uncached call from the outer call, it should make the page process faster after caching.
        • 12508
        • 63 Posts
        christian,

        it works! Thank you very much for your help.
          • 6038
          • 228 Posts
          glad to help smiley
            • 36624
            • 535 Posts
            i know you didn't ask but you should be aware of nested getResource call, this should be a issue when scaling. To gain speed you should use &includeTVList=`customerLogo` and &includeContent=`0` in your first call then (very important!) never use getResources uncached (you must cache [[ the both call).
              CTRL+SHIFT+U - Clear Cache
              CTRL+SHIFT+H - Hiding Heft Panel
              CTRL+SHIFT+N - Fast Create Resource
              CTRL+ALT+P - Preview Recource (in edit resorce window)
              CTRL+ALT+S - Save
              • 12508
              • 63 Posts
              Quote from: emmanuel at Nov 27, 2012, 11:35 PM
              i know you didn't ask but you should be aware of nested getResource call, this should be a issue when scaling. To gain speed you should use &includeTVList=`customerLogo` and &includeContent=`0` in your first call then (very important!) never use getResources uncached (you must cache [[ the both call).

              Thank you Emmanuel, I made your suggested changes and it works great!