We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39583
    • 103 Posts
    I am using the following to get some resources:
    [ [getResources?
    &parents=`-1,51,52,53`
    &limit=`20`
    &tpl=`getTeamMembers`
    &showHidden=`1`
    &depth=`1`
    &includeTVs=`1`
    &processTVs=`1`
    &includeContent=`1`
    &sortby=`RAND()`] ]

    But there is a child resource to 51 that doesn't show up. If I go in to that resource and make a change like adding a space to summary and then save it shows up with the code above. And then after a few hours it disappears again. And its only that specific resource every time.

    Any suggestions of what I could do to fix this?
      --
      André
      • 22840
      • 1,572 Posts
      Sounds like it's not published, so when you go into make the change your logged into the manager so can see unpublished resources on the front end, but when you go back to it your not logged into the manager ?
        • 39932
        • 483 Posts
        There are two problems to the code above that may cause this. First, the snippet is called cached. This means that it will only reevaluate whenever the cache for that object expires. This would explain why it works for a bit and then disappears for long periods of time. Fix this using (!), like so:

        [[!getResources?
          ...
          ...
        ]]
        


        Second, the results are indeterminate as you are doing sorting by RAND(). This means that if you have more than 20 children total, it may or may not show up at all. I say this may potentially be a problem because of the way many machines handle random numbers. End Points are often least represented. That is: in a distribution from 1 to 5, 5 is often the least represented in the result set. Since it is cached, if it doesn't show, it won't show for a long time. If you want it to show up all the time, change your sorting. If you must have random sorting, change to uncached (!). One or the other should provide consistent results.

        Finally, you may increase the limit to insure that all of the children are gotten, but looking at your code, I'm assuming there is a reason you wanted RAND to begin with, and that is because you are either a) anticipating a lot of results, or b) have limited real estate.
        [ed. note: fuzzicallogic last edited this post 14 years, 2 months ago.]
          Website: Extended Dialog Development Blog: on Extended Dialog
          Add-ons: AJAX Revolution, RO.IDEs Editor & Framework (in works) Utilities: Plugin Compatibility List
          Tutorials: Create Cross-Context Resources, Cross-Context AJAX Login, Template-Based Actions, Remove Extensions from URLs

          Failure is just another word for saying you didn't want to try. "It can't be done" means "I don't know how".
          • 39583
          • 103 Posts
          Thanks for your suggestions guys.

          Paulp -> Yes that specific resource is published.

          fuzzicallogic -> I just tried adding the (!) to getResources, no luck. And there are 9 child documents so I but 20 just to be sure I got all. And yes I need RAND(), but I have also tried sorting by index and I'm still getting the same result so its not that either.


          Now the weird thing is that the resource in question is not showing in the phones I'm testing the site on, but it is showing up in the desktop browser.
            --
            André
            • 22303 MODX Staff
            • 10,725 Posts
            Also, why is -1 in your list of parents? Take that out.
              • 39583
              • 103 Posts
              opengeek -> One of the pages I have showed the parents too when I didn't have -1. But now for some reason it works without it. So its gone. How ever, the problem with the missing resource happened before -1 was added. I deleted that resource and recreated a new one and so far it works. But we'll see in 24 hours.
                --
                André