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

    Hope someone can help me with this:

    [[!getResources?
    &sortby=`RAND()`
    &limit=`1`
    &tpl=`resources-rows`
    &parents=`171,63,87,288,294,295,284`
    &showHidden=`1`
    &includeContent=`1`
    &includeTVs=`1`
    &processTVs=`1`
    ]]

    It's for a custom homepage slider. Works great but I need it pull specific data based on ID:

    171 - only choose latest 3 posts
    63 - only choose latest 3 posts
    87 - choose all
    288 - choose all
    294 - choose all
    295 - choose all
    284 - choose all

    Is this possible? I've tried different where statements but none seem to work.

    Thanks so much in advance for anyone that can help! [ed. note: captain.janeway last edited this post 12 years, 8 months ago.]
      • 42822
      • 21 Posts
      You could call a separat tag for each resource.

      if the random sort is important to you, try this unelegant solution:
      create two resources x and y containing

      [[!getResources?
      &sortby=`RAND()`
      &limit=`3`
      &tpl=`resources-rows`
      &parents=`171,63`
      &showHidden=`1`
      &includeContent=`1`
      &includeTVs=`1`
      &processTVs=`1`
      ]]

      and
      [[!getResources?
      &sortby=`RAND()`
      &limit=`0`
      &tpl=`resources-rows`
      &parents=`87,288,294,295,284`
      &showHidden=`1`
      &includeContent=`1`
      &includeTVs=`1`
      &processTVs=`1`
      ]]


      and call them
      [[!getResources?
      &sortby=`RAND()`
      &limit=`0`
      &tpl=`@INLINE [[+content]]`
      &resources=`x,y`
      &showHidden=`1`
      &includeContent=`1`
      ]]
        • 45153
        • 6 Posts
        Thank you so much or your quick reply!

        I'm passing this on to our devs to see if they can get it working.

        I'll post our results.

        Thanks again smiley

        -Danielle
          • 45153
          • 6 Posts
          Unfortunately the solution did not work as I'd hoped.

          Resource 332 calls 1st chunk:
          [[!getResources?
          &sortby=`RAND()`
          &limit=`3`
          &tpl=`hpanimation-resources-rows`
          &parents=`171,63`
          &showHidden=`1`
          &includeContent=`1`
          &includeTVs=`1`
          &processTVs=`1`
          ]]

          Resource 333 calls 2nd chunk:
          [[!getResources?
          &sortby=`RAND()`
          &limit=`0`
          &tpl=`resources-rows`
          &parents=`87,288,294,295,284`
          &showHidden=`1`
          &includeContent=`1`
          &includeTVs=`1`
          &processTVs=`1`
          ]]

          And finally I call this:
          [[!getResources?
          &sortby=`RAND()`
          &limit=`1`
          &tpl=`@INLINE [[+content]]`
          &resources=`332,333`
          &showHidden=`1`
          &includeContent=`1`
          ]]

          But it's not displaying only 1 from each of 332 and 333. It shows all from 333 and 3 from 332. [ed. note: captain.janeway last edited this post 12 years, 8 months ago.]
            • 45153
            • 6 Posts
            In case anyone is interested here's an example of what I wound up doing.

            resource1 (news chunk, get latest)
            [[!getResources?
            &sortBy=`publishedOn`
            &sortdir=`DESC`
            &limit=`1`
            &tpl=`resources-rows`
            &parents=`63`
            &showHidden=`1`
            &includeContent=`1`
            &includeTVs=`1`
            &processTVs=`1`
            ]]

            resource2 (blog chunk, get latest)
            [[!getResources?
            &sortBy=`publishedOn`
            &sortdir=`DESC`
            &limit=`1`
            &tpl=`resources-rows`
            &parents=`171`
            &showHidden=`1`
            &includeContent=`1`
            &includeTVs=`1`
            &processTVs=`1`
            ]]

            resource3 (all others, pick random)
            [[!getResources:ifempty=`[[$resource1]]`? //show news in case any are empty
            &sortBy=`rand()`
            &limit=`1`
            &tpl=`resources-rows`
            &parents=`288,294,295`
            &showHidden=`1`
            &includeContent=`1`
            &includeTVs=`1`
            &processTVs=`1`
            ]]

            Select Random Snippet
            <?php
            $randomChunkName = isset($randomChunkName) ? $randomChunkName : 'randomChunk';
            $noOfChunks = isset($noOfChunks) ? $noOfChunks : '0';
            echo '[[' . $randomChunkName . rand(1, ($noOfChunks)) . ']]';

            Call the whole thing
            [[!randomChunk? &noOfChunks=`3` &randomChunkName=`$resource`]]