We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    Ok, in getResources itself it turns out to be in line 219:
        $criteria[] = "(modResource.context_key IN ({$context}) OR EXISTS(SELECT 1 FROM {$contextResourceTbl} ctx WHERE ctx.resource = modResource.id AND ctx.context_key IN ({$context})))";
    


    I'm inclined to suspect a bug in your specific version of MySQL.

    The pdoTools package's pdoResources snippet doesn't appear to use this query, so you might want to try it instead.
      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
      • 47430
      • 23 Posts
      Thank you! Sottwell.

      Yes, you are right again! You are so smart smiley

      I have tried disable snippets in the template one by one, and evetually figured out it's getResources' fault.

      Below is my code, for getting resources within some Collection Containers from several context:

      <ul class="dropdown-menu">
      <li class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
      <h4 class="text-center" style="border-bottom:1px solid #fff;"><a href="[[~15]]">IT Department</a></h4>
      <ul>
      [[!getResources1?
      &context=`itec`
      &parents=`55`
      &where=`{"class_key:!=":"CollectionContainer"}`
      &depth=`5`
      &limit=`50`
      &tpl=`MajorMenuItem`
      &debug=`0`
      ]]
      </ul>
      </li>
      <li class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
      <h4 class="text-center" style="border-bottom:1px solid #fff;"><a href="[[~27]]">Construction and Folk Arts</a></h4>
      <ul>
      [[!getResources1?
      &context=`consfolk`
      &parents=`55`
      &where=`{"class_key:!=":"CollectionContainer"}`
      &depth=`5`
      &limit=`50`
      &tpl=`MajorMenuItem`
      &debug=`0`
      ]]
      </ul>
      </li>
      <li class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
      <h4 class="text-center" style="border-bottom:1px solid #fff;"><a href="[[~44]]">Mechenical and Electric Engineering Department </a></h4>
      <ul>
      [[!getResources1?
      &context=`mechelec`
      &parents=`55`
      &where=`{"class_key:!=":"CollectionContainer"}`
      &depth=`5`
      &limit=`50`
      &tpl=`MajorMenuItem`
      &debug=`0`
      ]]
      </ul>
      </li>
      <li class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
      <h4 class="text-center" style="border-bottom:1px solid #fff;"><a href="[[~45]]">Chemical and Biological Department</a></h4>
      <ul>
      [[!getResources1?
      &context=`chembiol`
      &parents=`55`
      &where=`{"class_key:!=":"CollectionContainer"}`
      &depth=`5`
      &limit=`50`
      &tpl=`MajorMenuItem`
      &debug=`0`
      ]]
      </ul>
      </li>
      <li class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
      <h4 class="text-center" style="border-bottom:1px solid #fff;"><a href="[[~43]]">Basic Teaching</a></h4>
      <ul>
      [[!getResources1?
      &context=`baseteac`
      &parents=`55`
      &where=`{"class_key:!=":"CollectionContainer"}`
      &depth=`5`
      &limit=`50`
      &tpl=`MajorMenuItem`
      &debug=`0`
      ]]
      </ul>
      </li>
      <li class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
      <h4 class="text-center" style="border-bottom:1px solid #fff;"><a href="[[~46]]">Luxi Branch</a></h4>
      <ul>
      [[!getResources?
      &context=`luxi`
      &parents=`55`
      &where=`{"class_key:!=":"CollectionContainer"}`
      &depth=`5`
      &limit=`50`
      &tpl=`MajorMenuItem`
      &debug=`0`
      ]]
      </ul>
      </li>
      </ul>

      I commented them out, error messages were gone! How come?!
      Is there a bug in getResources?

        • 47430
        • 23 Posts
        getResources1 -- just a fast comment method for me. smiley
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Official comment syntax [[-SnippetName]]
            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
            • 47430
            • 23 Posts
            Thank you! I'll take that one from now on...

              • 47430
              • 23 Posts
              I got rid of the lines &context=`...` from my code, then all error messages were gone!
              If you know why, please let me know.


              Below is from getResourses' official help--

              context: Comma-delimited list of context keys to limit results by; if empty, contexts for all specified parents will be used (all contexts if 0 is specified)
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                As I said before, I suspect a bug in your particular version of MySQL. I've used getResources with contexts several times with no problems.

                I rarely use getResources any more, I always use pdoTools and its pdoResources snippet. It uses a totally different way of building the query, so it doesn't have that problem.
                  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
                  • 47430
                  • 23 Posts
                  Thank you! Sottwell. I'll try pdoTools.
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    The documentation to pdoTools and all of its snippets is in Russian, but the properties are very similar to getResources. In most cases, you can just change the getResources snippet name to pdoResources with no difference at all.
                      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
                      • 49529
                      • 196 Posts
                      artman328, maybe your issue is related to this one?

                      https://github.com/modxcms/revolution/issues/11276