We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27889
    • 415 Posts
    New version by Mark http://modxcms.com/Results-Per-Page-1574.html
    Thanks Mark to allow doing this so easy !

    This small tips allow the user to select how many result are displayed on the page.
    It can be modified to add other choice, date asc, desc ...

    First: you must call Ditto with the parameter : &extenders=`request`
    Two: add this small snippet and call it just before your ditto call

    Note: Requires Ditto 2
    Use this code as you want.
    Edit (Mark) : There is a new version available here that supports Ditto’s &id parameter. The previous version by Soda is still available below.
    <?php
    $choix_res_per_page=array(0,1,2,3,4,5,6,10);// Enter the differents choice you would allow
    $default_value=3;  // The default choice value
    $label_choice='Results per page:'; // The label for the field
    $go='Go'; //label for the form's button
    
    $nbres=(isset ($_GET['ditto_summarize']))?$_GET['ditto_summarize'] :$default_value;
        echo <<<END
       <form method="get">
        <label for="nbres">$label_choice</label>
        <select name="ditto_summarize" id="ditto_summarize">
    END;
        foreach ($choix_res_per_page as $value ){
          $selectedres=($value==$nbres)?' selected="selected"':'';
          echo "  <option value=\"$value\"$selectedres>$value</option>\n";
        }
        echo "</select>";
      echo <<<END
      <input class="boutton" value="$go" type="submit"></p>
      </form>
    END;
    ?>
    


    Example call:
    [!ResPerPage!]
    [!Ditto? &parent=`29` &extenders=`request` paginate=`1`!]
      MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
      MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]
    • Very cool tip. laugh
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 33337
        • 3,975 Posts
        Zaigham (aka zi) Reply #3, 17 years ago
        Awesome contribution man!

        Thanks a ton.

        regards.
          Zaigham R - MODX Professional | Skype | Email | Twitter

          Digging the interwebs for #MODX gems and bringing it to you. modx.link
          • 6726
          • 7,075 Posts
          I had missed that one, Nice one David smiley !
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l&#39;outil id
            • 18397
            • 3,250 Posts
            Here is a new version that supports Ditto’s &id parameter. Also, the variable names have been changed to their English equivalents.
            http://modxcms.com/Results-Per-Page-1574.html
              • 16545
              • 358 Posts
              Hello,
              very useful snippet, but it could be more useful without "go" button.

              It must be smth. like that ->


              // place this javascript code just before the </head> tag

              function doSel(obj)
              {
              for (i = 1; i < obj.length; i++)
              if (obj[i].selected == true)
              eval(obj[i].value);
              }


              <!-- this HTML code goes between your <body> tags -->

              <form name="jsMenu">
              <select name="jsSelList" size="1" onchange="doSel(this)">
              <option selected value>Select a page, and Gone!</option>
              <option value="location.href=’dHTML1.html’">Dynamic HTML 1</option>
              <option value="location.href=’validForm.html’">Validating Form 1</option>
              <option value="location.href=’../index.html’">GrassBlade Home Page</option>
              <option value="location.href=’validSSN.html’">Validating SSN</option>
              <option value="location.href=’selSwitch.html’">Multiple Select Swap</option>
              </select>
              </form>

              Maybe somebody can do it in php?
                • 27330
                • 884 Posts
                I can see the drop down when I use this, but the results doesn’t change when I make a selection.
                is there a way to troubleshoot this?
                  • 27330
                  • 884 Posts
                  ok I figured my problem, since my ditto call has an id set the results didn’t update after selection. If I remove my id parameter from the ditto call it works as expected.

                  the request extender page says
                  Note:
                  If a Ditto id is set use the sntax


                  so I opened the snippet and replaced the ($_GET[’ditto_summarize’])) with ($_GET[’dittoMyId_summarize’]))
                  which is shown in the URL now but doesn’t sort the results.

                  what exactly does If a Ditto id is set use the sntax means and where do I set the ID?

                    • 27330
                    • 884 Posts
                    Also tried Mark’s version which suppose to support the ID parameter but no luck there. anyone mind chiming in with advice what can be my issue?
                      • 23183
                      • 102 Posts
                      Thanks for this snippet.

                      I am also having the problem with &id causing the snippet not to work.

                      Also when I remove the &id and the drop down list works, pagination does not show anymore - has anyone got around this problem?

                      I only really want to use this snippet to add a ’show all’ link, is there a more efficient way to do this?

                      Thanks