We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20135
    • 188 Posts
    Hi all,

    I have a problem where gR is displaying the "grand-"children of the parent I specify (which I don't want), before listing the children that I want.

    Here's the current resource structure from the Resource List:

    Home (1) (home template contains gR call)
    ...
    Products (4)
      - Product 1 (7)
         - option 1 (9)
         - option 2 (10)
         - option 3 (41)
         - option 4 (47)
      - Product 2 (8)
         - option 1 (11)
         - option 2 (12)
    etc...


    Here's the gR call in the Home page tpl:
    [[!getResources ? &parents=`4` &tpl=`gr_ProductsListHome` &depth=`1`]]


    Here's what I expect to see listed:

    Product 1 (7)
    Product 2 (8)

    Here's what is being displayed:

    option 1 (9)
    option 2 (10)
    option 1 (11)
    option 2 (12)
    option 3 (41)
    option 4 (47)
    Product 1 (7)
    Product 2 (8)

    Running with debug, I am able to see that there is a fault in the SQL relative to the snippet call:

    ...WHERE ( modResource.parent IN (4,7,8) AND...
    SELECT `modResource`.`id`, `modResource`.`type`, ...
    ... 
    ... `modResource`.`properties` FROM `modx_site_content` AS `modResource` WHERE  ( modResource.parent IN (4,7,8) AND `modResource`.`deleted` = 0 AND `modResource`.`published` = 1 AND `modResource`.`hidemenu` = 0 )  ORDER BY publishedon DESC


    There doesn't seem to be a reason as to why 7 and 8 should be included in that SQL statement. Specifying &resources works fine, but I need to have the flexibility of automatically listing any immediate children of (4).

    Can anyone assist please? My current guess is that there is something faulty that requires a reinstall of MODx and/or gR (have already reinstalled gR once, with no success).

    [PS - for what it may matter, Products (4) and all Option resources (ids 9-47) are weblinks; however, that has not been a stumbling block in the past.]

    [PPS - I'm wondering if there might be a connected event. I tried to edit the limit property in the getResources snippet itself, but there are issues saving the changes, and the change is not reflected in the db. Network tab in Developer Tools shows that the POST command to /connectors/elements/snippet.php is returning a 404 error. Could this error be connected?]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Your 404 error could have something to do with mod_security or suhosin or some other server-side security configuration refusing to allow the POST. Perhaps the snippet code being sent by the POST is too long.

      As far as how getResources behaves when fetching multiple levels, I've noticed this myself recently. I haven't been able to figure out how to deal with it.
        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
        • 20135
        • 188 Posts
        @sottwell: Thanks. Neither suhosin nor mod_security look to be enabled. But is this something that could affect other functions? If not I won't follow that up further.

        Could there be a problem with the &depth property in this case? Without knowing how it's built, it would seem that the depth property is still feeding into the parents property that goes to the SQL statement. Obviously, if parents has only one value (in this case, 4), then something else is adding more ids to the statement (7 and cool.

        I'm guessing you're more aware of other errors and faulty outputs than I. If you have any suggestions that could help both of us, I'm all ears...
          • 36996
          • 211 Posts
          What happens when you try depth=`0`?
            • 20135
            • 188 Posts
            Quote from: nir-z at Mar 30, 2014, 11:55 PM
            What happens when you try depth=`0`?
            Amazingly, it shows just the children, not the grand-children. It doesn't make sense, but that might be the solution.

            Thanks Nir.
              • 36996
              • 211 Posts
              Glad to help.
              Actually, it does make sense because the parents are never shown, so the first level is 0 (if it's zero based).