We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50923
    • 137 Posts
    I am using this addon

    https://docs.modx.com/extras/revo/peoples/peoples.peoples

    But i have problem i want to sort and limit users by random, i have tried like this

    [[!Peoples? &limit=`4` &tpl=`OurTeamRowTpl` &sortby=`RAND()`]]


    But it does not work, it always gets four users starting from first, is there some property that I can extend, txanks
      <a href="www.play2web.com" title="izrada web sajtova">Izrada web sajtova</a>
      • 3749
      • 24,544 Posts
      Try &sortBy (capital B).
        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
        • 50923
        • 137 Posts
        No luck, now nothing is showing sad
          <a href="www.play2web.com" title="izrada web sajtova">Izrada web sajtova</a>
          • 3749
          • 24,544 Posts
          It's definitely &sortBy. This is from the Peoples snippet code:

          $sortBy = $modx->getOption('sortBy',$scriptProperties,'username');


          That said, I got the same result you did. It was working before because that property was ignored. When it's typed correctly, Peoples turns it into this, which apparently won't fly:

          $c->sortby('User.RAND()','ASC');


          I think you'll need a custom snippet.

          Try this:

          [[!ShowUsers]]


          /* ShowUsers snippet */
          $output = '';
          $c = $modx->newQuery('modUser');
          $c->sortby('RAND()');
          $c->limit(4);
          $c->where(
              array('modUser.active' => true)
          );
          $users = $modx->getCollectionGraph('modUser', '{"Profile":{} }', $c);
          
          foreach ($users as $user) {
          
              $fields = array_merge($user->toArray(), $user->Profile->toArray());
              $output .= $modx->getChunk('OurTeamRowTpl', $fields);
          
          }
          
          return $output;

            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
            • 50923
            • 137 Posts
            Txanks, but i just edite People snippet like this

            if (!empty($randomOrder)) {
                shuffle($list);
                if ($randomOrder > 0) {
                $list = array_splice($list, 0, $randomOrder);
                }
            }



            And call it like this
            [[!Peoples? &tpl=`OurTeamTestemonialsRowTpl` &randomOrder=`1` &limit=`0`]]
              <a href="www.play2web.com" title="izrada web sajtova">Izrada web sajtova</a>