We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24017
    • 88 Posts
    Hi, I've been tryin the getresources function and it seems like I'm doing something wrong and could do with some help ...

    What I did is :

    1 - I set up a chunk with tha piece of code

    <ul>
     <li><h2><a href="[[~[[+id]]]]" title="[[+pagetitle]]">[[+pagetitle]]</a></h2>
      <p class="readmore"><a href="[[~[[+id]]]]"><span>Read more</span></a></p></li></ul>
      <div class="clear"></div>
    <hr/>


    2 - I set up a couple of resources that are all parents of Resource ID 1

    3 - In the parent resource I put the following code

    [[!getResources? &parents=`[[*1]]` &tpl=`blogListPost` &sortby=`menuindex` &includeContent=`1`]]


    What I am getting so far is a page that displays a link to the parent resource, but it does not list anything else ... Not sure what I am doing wrong, any help will be appreciated as, it is very difficult to find some simple tutorials for modx out there... Many thanks
      • 3749
      • 24,544 Posts
      I can't really tell what you're trying to do, but the &parents property is definitely wrong. Try this and see if it does the trick:

      &parents=`[[*id]]`


      That will show the children of the resource with the getResources tag.

      BTW, a resource only has one parent, so only one resource can be the parent of any given resource. Did you maybe mean that the resources are 'children' of Resource ID 1?



      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 24017
        • 88 Posts
        Thanks for the reply I'm getting very confused ... I actually followed all the instructions in the documentation as well as some tutorial I found on the net .. but I'm surely doing something wrong or not understanding everything so far ... what I am trying to do is to set up a kind of catalog, where I will have a page showing a list of items (with title, summary ..) and a link to the appropriate resource .... From what I understood the getresource property is what I should be using ?...

        I do have resources set as children of resource ID 1 , and I am trying to get the list of all children , but all I am getting is a link to the parent resource .... Many thanks for your help
          • 3749
          • 24,544 Posts
          Make sure the Tpl chunk is called blogListPost (exactly as in the tag - it's case-sensitive), and put this in the Resource Content field of the parent page:


          [[!getResources? &parents=`[[*id]]` &tpl=`blogListPost` &sortby=`menuindex` &includeContent=`1`]]


          Remove the ul and li tags from the Tpl chunk for now.

          When you preview the parent page, you should see the children if they are set to be published and not hidden from menus.


          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html


            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 33968
            • 863 Posts
            If this snippet is going to be shown on multiple pages and the resources are always going to be children of resource 1, then this is how you'll do it:
            [[getResources? &parents=`1` &tpl=`blogListPost` &sortby=`menuindex` &includeContent=`1`]]
            


            However if's always meant to show resources that are children of the *current* resource, then you'll do this:
            [[getResources? &parents=`[[*id]]` &tpl=`blogListPost` &sortby=`menuindex` &includeContent=`1`]]
            

            [ [*id]] will always be populated with the id of the current resource.
              • 24017
              • 88 Posts
              guys, I thank you so much for your help !! You just made my day after so many hours trying to understand where the pb could come from ... For some reason one of the resources was not set to "published" so big up Bob for your checklist that really helped me !

              Now when I read both of your comments I see that Bob is writing [[!getResources and Lucas without the ! , what is the definite good use ? Is it that the ! is left from other versions or something like that ?

              Again many thanks!
                • 32316
                • 387 Posts
                whistlemaker Reply #7, 12 years ago
                Is it that the ! is left from other versions or something like that ?
                No - if it starts: [[!blah it is an uncached call, and [[blah is a cached call
                  • 24017
                  • 88 Posts
                  thank you !
                    • 33968
                    • 863 Posts
                    @ptityop - it's best to use the ! uncached version during development and testing but use the cached version for the live site. That way the snippet won't have to run for every page view (the results will be saved to a file in the cache) and your pages will load much faster smiley

                    It's really only necessary to use an uncached snippet when the data it returns is likely to change often.