Forums

[Plugin: Members List Plugin] Repeat page links at bottom of list. (2 posts)

  1. ibgap
    Member
    Posted 2 years ago #

    How can I repeat the pagination links at the bottom of my member list.

    http://wordpress.org/extend/plugins/members-list/

  2. mpraetzel
    Member
    Posted 2 years ago #

    ibgap,

    That is a great question. There two things you need to do.

    First we need to change a function in the plugin file tern_wp_members.php. The function starts on line 722.

    Change the function "pagination" to this:

    function pagination($d=true) {
    		global $tern_wp_members_defaults;
    		$o = $this->wp->getOption('tern_wp_members',$tern_wp_members_defaults);
    		$q = $_GET['query'];
    		$b = $_GET['by'];
    		$t = $_GET['type'];
    		$this->scope();
    		if($this->n > 1) {
    			$s = $this->p-2;
    			$e = ($s+4)>$this->n ? $this->n : $s+4;
    			if($s <= 0) {
    				$s = 1;
    				$e = ($s+4)>$this->n ? $this->n : $s+4;
    			}
    			elseif(($this->p+2) > $this->n) {
    				$e = $this->n;
    				$s = ($e-4)<=0 ? 1 : $e-4;
    			}
    			$sort = empty($_GET['sort']) ? $o['sort'] : $_GET['sort'];
    			$order = empty($_GET['order']) ? $o['order'] : $_GET['order'];
    			for($i=$s;$i<=$e;$i++) {
    				$h = $this->url.'&page='.($i).'&query='.$q.'&by='.$b.'&type='.$t.'&sort='.$sort.'&order='.$order;
    				$c = intval($this->s+1) == $i ? ' class="tern_members_pagination_current tern_pagination_current"' : '';
    				$r .= '<li'.$c.'><a href="' . $h . '">' . $i . '</a></li>';
    			}
    			if($this->s > 0) {
    				$r = '<li><a href="'.$this->url.'&page='.intval($this->s).'&query='.$q.'&by='.$b.'&type='.$t.'&sort='.$sort.'&order='.$order.'">Previous</a></li>'.$r;
    			}
    			if($this->total > (($this->s*$this->num)+$this->num)) {
    				$r .= '<li><a href="'.$this->url.'&page='.intval($this->s+2).'&query='.$q.'&by='.$b.'&type='.$t.'&sort='.$sort.'&order='.$order.'">Next</a></li>';
    				$r .= '<li><a href="'.$this->url.'&page='.$this->n.'&query='.$q.'&by='.$b.'&type='.$t.'&sort='.$sort.'&order='.$order.'">Last</a></li>';
    			}
    			$r = $this->s > 0 ? '<li><a href="'.$this->url.'&page=1&query='.$q.'&by='.$b.'&type='.$t.'&sort='.$sort.'&order='.$order.'">First</a></li>'.$r : $r;
    			$r = '<ul class="tern_members_pagination tern_wp_pagination tern_pagination">' . $r . '</ul>';
    		}
    		$m = '.';
    		if($t == 'alpha') {
    			$m = ' whose last names begin with the letter "'.strtoupper($q).'".';
    		}
    		$v = $this->total > 0 ? (($this->s*$this->num)+1) : '0';
    		if($d) {
    			echo '<div id="tern_members_pagination"><p>Now viewing <b>' . $v . '</b> through <b>' . $this->e . '</b> of <b>'.$this->total.'</b> members found'.$m.'</p>';
    		}
    		echo $d ? $r.'</div>' : $r;
    	}

    Second we need to add the code to print the pagination into your template.

    Change the code you added to your members.php file from this:

    <?php
         $members = new tern_members;
         $members->members(array('search'=>true,'pagination'=>true,'sort'=>true));
    ?>

    To this:

    <?php
         $members = new tern_members;
         $members->members(array('search'=>true,'pagination'=>true,'sort'=>true));
         $members->pagination(false);
    ?>

    That should do it. Let me know how you fare.

    ~ matthew

Topic Closed

This topic has been closed to new replies.

About this Topic