Aug 08, 2008, 01:35 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: [Tutorial] Results Per Page Form Dropdown  (Read 9599 times)
0 Members and 1 Guest are viewing this topic.
Soda
Testers
*
Posts: 415


Daddy !


WWW
« on: Mar 18, 2007, 12:33 AM »

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.
Code:
<?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`!]
« Last Edit: Aug 22, 2007, 08:13 AM by Soda » Logged

MODx Sites & Prestations: http://dp-site.fr   [Last MODx Site]
MODx Repository: [HOME]  [MetaTagsExtra] / Current Dev: [xFDM]
rthrash
Foundation
*
Posts: 9,032



WWW
« Reply #1 on: Mar 18, 2007, 08:51 AM »

Very cool tip. Cheesy
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
zi
MODx Special Forces /
Administrator
*
Posts: 2,903


May Peace Be On You


WWW
« Reply #2 on: Apr 17, 2007, 01:43 PM »

Awesome contribution man!

Thanks a ton.

regards.
Logged

“Internet Explorer’s CSS rendering: WYSIWTF”. — someone genius
--------------------------------------------------
davidm
Marketing & Design Team
*
Posts: 6,526


The best way to predict the future is to invent it


WWW
« Reply #3 on: May 03, 2007, 04:19 AM »

I had missed that one, Nice one David Smiley  !
Logged

blog.nodeo.net : Pour un web libre, moderne et ouvert! :: | ! Nouveau ! Les forums modxcms.fr : Participez à l'élaboration du site MODx francophone ! ! Nouveau ! :.

MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accès pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.45 - PHP 5.2.5 | Debian 4.0 (Etch)

Réalisations sous MODx : nodeo.net | gican.asso.fr | michelez-notaires.com | amadom.gerondicap.com | sworld.com | soleil.info
 et 3 autres en cours de réalisation Smiley
Mark
Moderator
*
Posts: 3,247


Ditto Developer


WWW
« Reply #4 on: Jul 30, 2007, 05:18 PM »

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
Logged

labasus
Jr. Member
*
Posts: 34


« Reply #5 on: May 25, 2008, 01:48 PM »

Hello,
 very useful snippet, but it could be more useful without "go" button.

It must be smth. like that ->

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

 function doSel(obj)
 {
     for (i = 1; i < obj.length; i++)
        if (obj.selected == true)
           eval(obj.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?
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF 1.1.4 | SMF © 2005, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!