We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46039
    • 76 Posts
    Re posting with a better title.

    I cannot seem to use getResources to get a page that has its own getResources call.

    The first call is dynamic, ie it calls a page based upon a changing alias.

    The target page has an explicit call via getresources to include the content of a shared resource, ie parents=-1 resource=7.

    When I try to do this, it just hangs. Is this normal behaviour or is something wrong?

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

    • It's possible that it's calling itself, thus creating an infinite loop.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 46039
        • 76 Posts
        Hey sottwell,

        Do you mean the target page may be the same, or the snippet is calling itself again?

        The target pages should never be the same, because they are in unrelated parts of the site with different parents.
        • Show me the first getResources snippet.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 46039
            • 76 Posts
            [[!getResources:default=`<div class="col-12"><p class="tpl-noresults">Your Client Page has not been generated yet.</p></div>`?
                &where=`{"alias:=":"[[+cid]]"}`
                &parents=`48`
                &depth=`0`
                &limit=`1`
                &includeContent=`1`
                &includeTVs=`0`
                &includeTVList=``
                &prepareTVs=`0`
                &processTVs=`0`
                &tvPrefix=`tv.`
                &hideContainers=`0`
                &showHidden=`1`
                &showUnpublished=`0`
                &resources=``
                &Xsortby=`{"menuindex":"ASC"}`
                &tpl=`@INLINE [[+content]]`
                &Xdebug=`1`
            ]]


            The second call on the client pages called a small portion of code that stated various things; which I'd rather have as an editable resource rather than a chunk.

            As I said, this works fine if I remove the getResources calls from the resulting content.
              • 46039
              • 76 Posts
              Could anyone verify that the above can work? Still haven't tracked down the issue.
              • Where is the [[+cid]] placeholder coming from?
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 46039
                  • 76 Posts
                  From a snippet. As I said above, this getresources call works fine; it gets the page, but if the page it finds has another getresources call the whole thing hangs.

                  I can't get it to work at all, but everything I'm reading online suggests that you can nest getresources all day long with no issues. It's incredibly confusing.
                  • Ok, what does the getResources call in the [[+content]] look like?

                    That [[+cid]] is the alias, or the ID of the resource? Never mind, looking things over I can see that it would be the alias, which is most likely the current user's username? [ed. note: sottwell last edited this post 8 years, 9 months ago.]
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 46039
                      • 76 Posts
                      Hey, CID is a client ID which can be shared by many user logins, CID is basically just a reference to a client's main client page and its also on all documents relating to their projects. I just started using this method; using classextender from Bobray.

                      The idea was that I reference a main client page, which then has many other getresources calls within it, to get lists of stuff like invoices, project specs, etc. Each request has a security layer that checks the CID of a resource against the logged in users CID. All of the security seems to work, but getresources is not.

                      Two example getresources calls I'm using so you can check for issues:

                      [[-!getResources:default=`<div class="col-12"><p class="tpl">You have no invoices.</p></div>`?
                          &parents=`49`
                          &depth=`0`
                          &limit=`100`
                          &includeContent=`1`
                          &includeTVs=`0`
                          &includeTVList=``
                          &prepareTVs=`0`
                          &processTVs=`0`
                          &tvPrefix=`tv.`
                          &hideContainers=`0`
                          &showHidden=`1`
                          &showUnpublished=`0`
                          &resources=``
                          &sortby=`{"menuindex":"ASC"}`
                          &tpl=`@INLINE [[+content]]`
                      ]]
                      
                      [[!getResources?
                          &parents=`-1`
                          &depth=`0`
                          &limit=`1`
                          &includeContent=`1`
                          &includeTVs=`0`
                          &includeTVList=``
                          &prepareTVs=`0`
                          &processTVs=`0`
                          &tvPrefix=`tv.`
                          &hideContainers=`0`
                          &showHidden=`1`
                          &showUnpublished=`0`
                          &resources=`1`
                          &sortby=`{"menuindex":"ASC"}`
                          &tpl=`@INLINE [[+content]]`
                      ]]


                      I have time to run more tests tonight, so I may update this post later with more confirmation or details; but any help or insight would be much appreciated.