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

    I hope he's not sick again...

    Seriously, nothing back on this?
      • 37033
      • 6 Posts
      Is this project dead? Or is it that just no one knows how to do what I'm asking about?
        • 4172
        • 5,888 Posts
        Didn't read all the posts above. What exactly is the result you are after?
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 37033
          • 6 Posts
          Hello Bruno,

          Thanks for the reply. My issue basically revolves around how to go about implementing this groupResources technique with getPage so that I can use it in conjunction with paginated resources.

          Reference my original post about it https://forums.modx.com/thread/69754/getresources---group-results?page=2#dis-post-459550. If you have any further questions on it from me or any additional code please do not hesitate to ask and I shall get back to you asap as I'd really like to find a solution.

          Thanks in advance!
            • 4172
            • 5,888 Posts
            I'm not sure how you want to paginate the grouped result and how you want to paginate a random result.

            If you want to paginate a random result, you will need to store the random order somehow or you will need to get the unpaginated result and paginate client-side by javascript.

            Any example - html?
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 43836
              • 2 Posts
              Quote from: damonwilliams at Mar 27, 2013, 12:31 PM
              Hello Bruno,

              Thanks for the reply. My issue basically revolves around how to go about implementing this groupResources technique with getPage so that I can use it in conjunction with paginated resources.

              Reference my original post about it https://forums.modx.com/thread/69754/getresources---group-results?page=2#dis-post-459550. If you have any further questions on it from me or any additional code please do not hesitate to ask and I shall get back to you asap as I'd really like to find a solution.

              Thanks in advance!

              This might help, I modified one of the snippets poster earlier to make this one. It will let you run any snippet and group its output for every nth child.

              Here is the snippet code
              <?php
              $output = '';
               
              $groupTag = $scriptProperties['groupTag'];
              $snip = $scriptProperties['snippet'];
              if(!isset($scriptProperties['outputSeparator'])) {
                  $scriptProperties['outputSeparator'] = '||';
              }
               
              if(!isset($groupTag)) {
                  $groupTag = 'ul';
              }
               
              if(isset($scriptProperties['groupClass'])) {
                  $markupOpen = $groupTag.' class="'.$scriptProperties['groupClass'].'"';
              } else {    
                  $markupOpen = $groupTag;
              }
               
              $rows = $modx->runSnippet($snip, $scriptProperties);
              $rows = explode($scriptProperties['outputSeparator'],$rows);
               
              $numItems = count($rows);
              foreach ($rows as $i => $row) {
                  $output .= $row;
                  if ($i == 0){
                      echo '<'.$markupOpen.'>';
                  }
                  if (($i + 1) % $scriptProperties['group'] == 0) {
                       
                      if($i != $numItems-1) {
                          $output .= "\n</".$groupTag.">\n<".$markupOpen.">\n";
                      } else {
                          $output .= "\n</".$groupTag.">\n";
                      }
                  }
              }
              return $output;


              This is the snippet call
              [[!GroupSeperator? &groupTag=`div` &groupClass=`row` &group=`3` &snippet=`getPage` &...getpage properties...]]


              so i guess your snippet call should look something like this.
              [[!GroupSeperator?
              &groupTag=`div`
              &groupClass=`row`
              &snippet=`getPage`
                  &elementClass=`modSnippet`
                  &element=`getResources`
               
                  &parents=`[[*id]]`
                  &limit=`32`
                  &sortby=`RAND()`
               
                  &includeContent=`0`
                  &includeTVs=`1`
                  &showHidden=`1`
                  &hideContainers=`1`
               
                  &tpl=`shopRowTpl`
              ]]
               
              [[!+page.nav:notempty=`<div class="paging"><div class="page-list">[[!+page.nav]]</div></div>`]]
              


              I may not be of much use if it throws a bnch of nonsense at you but I have it running on a getpage call and also using minishop, and it works just fine.