We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36632
    • 202 Posts
    Peter Bockenthien Reply #1, 10 years ago
    I have a directory with various resources published and hidden. My getResources call is in the template:
    [[!getResources? &parents=`43` &resources=`44,45,46` &limit=`1` &showHidden=`1` &tpl=`random` &tvPrefix=`` &includeTVs=`1` &includeContent`1` &sortby=`RAND()`]]
    


    What I want: display 1 Resource randomly in the Sidebar of the template. I have 3 now but will wind up with 50+.

    What it actually does: displays the content of the Resource. Instead of this Primary Resources and a Random Resources in the Sidebar, I have the Primary Resources displaying in both places. If the Resource is blank, the Sidebar is blank.

    I can't figure out what I'm doing wrong.

    Revo 2.3.2 on MODXCloud, getResources 1.6.1 [ed. note: ultrasef last edited this post 10 years ago.]
      • 38850
      • 110 Posts
      Couple suggestions.

      Use of parents as well as resources has unexpected behavior. If you use the resources list, then set parents to "-1" to basically disable it. If you want to use parents (so that is selects all the children of that parent) then don't use resources.

      You are using a chunk named "random" to display the selected resource, so if you are getting unexpected output, it's probably because of the chunk and what it's displaying. Can you post the code of the chunk here as well?

      When you say you want to display the resource in the sidebar, which part are you talking about? Do you want to show a snippet of content? Just its title with a link? The summary text? You are using "&includeContent`1`" which means getResources will include the main content of the resource. It sounds like you don't want the content of the resource, so you should probably not set that property just to save memory.

      Let us know if that helps and what your "random" chunk content is.
        • 36632
        • 202 Posts
        Peter Bockenthien Reply #3, 10 years ago
        I changed the snippet call to &parents=`xx` and removed &resources. It displays on the first template tag in the chunk named `random` :
        <h3>[[+pagetitle]]</h3>
        [[+content]]
        

        but it doesn't display the `content` tag. Kinda odd because I do have the &includeContent=`1` in the snippet call.
          • 38850
          • 110 Posts
          Quote from: ultrasef at Dec 05, 2014, 07:51 PM
          I changed the snippet call to &parents=`xx` and removed &resources. It displays on the first template tag in the chunk named `random` :
          <h3>[[+pagetitle]]</h3>
          [[+content]]
          

          but it doesn't display the `content` tag. Kinda odd because I do have the &includeContent=`1` in the snippet call.

          Oh, that property is missing the equal sign. In your original snippet call you had "&includeContent`1`" instead of "&includeContent=`1`"
            • 36632
            • 202 Posts
            Peter Bockenthien Reply #5, 10 years ago
            Duh! Thanks vigilante. I need to get back to reading outloud.