[Mediawiki-l] How can i paginate database query?

Jim Hu jimhu at tamu.edu
Mon Sep 3 17:04:49 UTC 2007


On Sep 2, 2007, at 5:16 PM, VicHaunter wrote:

> Hello,
> I'm creating a extension that show a list of articles included in  
> two categories.
> The problem is that some ones have a lot of results and i can't  
> paginate with ordynary methods because the wiki dont get my vars  
> across the urls bar.

Look at wfViewPrevNext in GlobalFunctions.php
To do paging in my UserRightsList Extension, this is what I did:

	function navLinks(){
		global $wgContLang;
		$atend = $this->num < $this->limit;
		$params = array();
		if( isset($this->yearfrom) ) 	$params['yearfrom']	= $this->yearfrom;
		if( isset($this->monthfrom) ) 	$params['monthfrom']	= $this- 
 >monthfrom;
		if( isset($this->yearto) ) 		$params['yearto'] 	= $this->yearto;
		if( isset($this->monthto) ) 	$params['monthto'] 	= $this->monthto;
		if( isset($this->username) )	$params['username'] 	= $this->username;
		if( isset($this->group) )		$params['group'] 	= $this->group;
		
		return wfViewPrevNext(
				$this->offset,
				$this->limit ,
				$wgContLang->specialPage( $this->getName() ),
				wfArrayToCGI( $params ),
				$atend  );
	}

The $params lets you pass your vars to the paging system.  The  
parameters I used were all set elsewhere in the script from  
$wgRequest.  Hope this helps.

Jim

>
> Someone knows how i can paginate a mysql query like the pagination  
> in the Categories in mediawiki with a extension?
> Thankyou
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l at lists.wikimedia.org
> http://lists.wikimedia.org/mailman/listinfo/mediawiki-l

=====================================
Jim Hu
Associate Professor
Dept. of Biochemistry and Biophysics
2128 TAMU
Texas A&M Univ.
College Station, TX 77843-2128
979-862-4054




More information about the MediaWiki-l mailing list