We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25330
    • 14 Posts
    I have a container that has multiple children resources. These resources all need to be shown all in their parent container but in other parts of the site only certain resources need displayed. So I have a chunk with my getResources call in it.

    [[!getResources?
    &resources=`[[+sections]]`
    &includeContent=`1`
    &sortby=`menuindex`
    &tpl=`isiTpl`
    &sortdir=`ASC`
    ]]

    Then on each resource I created a template variable where I call that chunk. [[$GRchunk? &sections=`74,75,76,77,78`]]

    This works perfectly on all resources except for ones that that have child resources themselves. These other container resources display their children as well as the ones sent to the getResources snippet.

    In the other container resources if I call the snippet with the &parents defined and not &resources it does grab the contents of that resource but grabs them all and not the specific ones that I need
    [[!getResources?
    &parents=`9`
    &includeContent=`1`
    &sortby=`menuindex`
    &tpl=`isiTpl`
    &sortdir=`ASC`
    ]]

    Hopefully I explained it clearly. Is this a bug or am I calling something out incorrectly?

    Using 2.0.8 and getResources 1.3.0
      • 33968
      • 863 Posts
      You could use &depth=`` to prevent the child resources being displayed.

      eg. If the resources you want to show are 2 levels deep, use &depth=`2`
        • 25330
        • 14 Posts
        Tried the dept and it seemed to ignore it as it kept spitting out the same output no matter what I put the depth to. Here is one of the Arrays its outputting. Even shows what [resources] are being called but at the same time has a completely different [id] from those resources. The parent of those resources called is 9 but the parent on this array is 2.

        Array
        (
        [tpl] =>
        [tplOdd] =>
        [tplFirst] =>
        [tplLast] =>
        [sortby] => menuindex
        [sortbyTV] =>
        [sortbyTVType] => string
        [sortbyAlias] =>
        [sortbyEscaped] => 0
        [sortdir] => ASC
        [sortdirTV] => DESC
        [limit] => 5
        [offset] => 0
        [tvFilters] =>
        [depth] => 2
        [parents] =>
        [includeContent] =>
        [includeTVs] =>
        [showHidden] =>
        [showUnpublished] =>
        [showDeleted] =>
        [resources] => 74,75,76,77,78
        [processTVs] =>
        [tvPrefix] => tv.
        [idx] => 1
        [first] => 1
        [last] => 5
        [toPlaceholder] =>
        [toSeparatePlaceholders] =>
        [debug] =>
        [where] =>
        [hideContainers] => 1
        [id] => 7
        [type] => document
        [contentType] => text/html
        [pagetitle] => Title
        [longtitle] =>
        [description] =>
        [alias] =>
        [link_attributes] =>
        [published] => 1
        [pub_date] => 0
        [unpub_date] => 0
        [parent] => 2
        [isfolder] =>
        [introtext] =>
        [richtext] => 1
        [template] => 1
        [menuindex] => 0
        [searchable] => 1
        [cacheable] => 1
        [createdby] => 1
        [createdon] => 2011-05-06 15:29:09
        [editedby] => 1
        [editedon] => 2011-05-17 03:20:04
        [deleted] =>
        [deletedon] => 0
        [deletedby] => 0
        [publishedon] => 2011-05-06 15:29:00
        [publishedby] => 1
        [menutitle] => Title
        [donthit] =>
        [haskeywords] =>
        [hasmetatags] =>
        [privateweb] =>
        [privatemgr] =>
        [content_dispo] => 0
        [hidemenu] => 0
        [class_key] => modDocument
        [context_key] => web
        [content_type] => 1
        )
          • 33968
          • 863 Posts
          Wondering if it’s some kind of caching issue seeing as you’ve nested the snippet inside a chunk.

          What happens if you call the chunk uncached, or try the GR call directly in your template:
          [[!getResources?
                &resources=`74,75,76,77,78`
                &depth=`2`
                &includeContent=`1`
                &sortby=`menuindex`
                &tpl=`isiTpl`
                &sortdir=`ASC` 
              ]]
          
            • 25330
            • 14 Posts
            Yep, I had it already cached and when putting the call directly in the resource with the resources defined it still has the same output.
              • 47166
              • 9 Posts
              Hello!

              I know the thread is a little bit outdated, but maybe my solution still helps someone out there.

              I had a similar situation and needed to refer to child resources through the whole website.

              This might be the site's structure:
              Home (1)
              + Services (4)
              | + Webdesign (17)
              | + Databases (18)
              | + MODx (19)
              + Contact (5)
              | + Success (12)
              + About us (8)
                + Testimonials (9)

              On every page I have the same quick navigation, that shall lead us to "Webdesign", "MODx", "Contact" and "Testimonials" and I want to have it sorted in exactly this order.

              With the already mentioned approaches I could not come to any conclusion, on the container pages ("Services", "Contact", "About us") the resources were displayed in a completely randomized way.

              I found a solution after adding the "&debug=`1`" parameter, that writes the generated SQL statement to the MODx log file.

              After that I added a "where" statement to my "getResources" call, so it now looks as follows:
              [[!getResources:default=`[[%nothing_found]]`?
                &tpl=`itemJumpTo` 
                &parents=`0,4,8` 
                &where=`{"modResource.id:IN":[17,19,5,9], 
                  "modResource.parent:IN":[0,4,8]}` 
                &includeContent=`1` 
                &showHidden=`1` 
                &sortby=`FIELD(modResource.id, 17,19,5,9)` 
                &sortdir=`ASC`]]

              And, what to say? The generated output is exactly the way we want it.

              I hope you might find this usefull. smiley