Add quick page selection to Wind theme on Gallery 3.0.1

andygp

Joined: 2010-12-22
Posts: 1
Posted: Thu, 2011-05-26 13:07

This is a response to this thread:

http://gallery.menalto.com/node/91300

Which i don't seem to be able to reply anymore.

I was trying to work out a way to place page numbers at the end of each page, which is handy when you have large numbers of photos, and you don't want the user to keep clicking on next/prev all the time, so they can jump directly to some other page.

I thought I'd share what I did.

Edit views\paginator.html.php

Add this to the end:

<?
	/* add drop down list pagination for quick jump to another page */
	if ($max_pages > 2) {
		echo "<div class='g-page-list' style='text-align:center'>Jump to Page <select style='display:inline' onchange='document.location.href=this.value;'>\n";
		for ($i=1;$i<=$max_pages;$i++) {
			if (strstr($_SERVER['QUERY_STRING'],'page=')) {
				$url = preg_replace('/page=(\d+)/','page='.$i,$_SERVER['REQUEST_URI']);
			} else {
				if (!$_SERVER['QUERY_STRING']) {
					$url = $_SERVER['REQUEST_URI'].'?page='.$i;
				} else {
					$url = $_SERVER['REQUEST_URI'].'&page='.$i;
				}
			}
			echo "<option value='".$url."'".($i == $page ? ' selected' : '' ).">".$i."</option>\n";
		}
		echo "</select></div>";
	}
?>

http://pastebin.com/BMb7PGf3