I rewrote the pagination in my local Blog module to take the form of "/blog/page/2" instead of "/blog/?start=10". This is extremely similar to how the "tag/whatever" works. The biggest problem is how the BlogPagination.ss include file relies on DataObjectSet's NextLink and PevLink, which I didn't want to rewrite (and probably shouldn't because of where they might be used).
in BlogTree.php -> BlogTree_Controller
add 'page' to $allowed_actions
modify inside method BlogEntries()
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
to be
if (isset($_GET['start'])) {
$start = (int) $_GET['start'];
} else {
$start = (int) $this->SelectedPage();
$start = $limit * ($start - 1);
}
Add these methods (preferably down by the SelectedTag()
/** - Added 7/14/2011 by Jared Kipe
* Return the currently viewing page, default is 1
*
* @return int
*/
function SelectedPage() {
return ($this->request->latestParam('Action') == 'page') ? max((int)$this->request->latestParam('ID'), 1) : 1;
}
function PreviousPage() {
return $this->SelectedPage() - 1;
}
function NextPage() {
return $this->SelectedPage() + 1;
}
// override for some parent's implementation of page that causes runtime error using the 'page' action
function page() {
return array();
}
This will take some modification to the BlogPagination.ss include file.
<% if BlogEntries.MoreThanOnePage %>
<div id="PageNumbers">
<p>
<% if BlogEntries.NotFirstPage %>
<a class="prev" href="{$Link}<% if PreviousPage != 1 %>page/$PreviousPage<% end_if %>" title="View the previous page">Prev</a>
<% end_if %>
<span>
<% control BlogEntries.PaginationSummary(4) %>
<% if CurrentBool %>
<span class="current">$PageNum</span>
<% else %>
<% if Link %>
<a href="{$Top.Link}page/$PageNum" title="View page number $PageNum">$PageNum</a>
<% else %>
…
<% end_if %>
<% end_if %>
<% end_control %>
</span>
<% if BlogEntries.NotLastPage %>
<a class="next" href="{$Link}page/$NextPage" title="View the next page">Next</a>
<% end_if %>
</p>
</div>
<% end_if %>
EDIT: After thinking about it, this could probably cause problems when using tags or date, if there are are so many of either to cause pagination. Probably wrap the BlogPagination.ss file with a giant <% if SelectedTag %> or use two different includes based on SelectedTag. Allowing you to use the "old" BlogPagination.ss file with ?start=10 instead.