Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

navigation in pagination


Go to End
Reply


4 Posts   2307 Views

Avatar
snaip

Community Member, 180 Posts

18 May 2010 at 9:37pm

hi

i have 20 pages with pagination
the default function in documentation http://doc.silverstripe.org/private:recipes:pagination get all page number in the list

<< prev 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 next >>

how to modify it to get

1,2,3,4, |5| .... 20 next >>

like in forum ?

what about 100 pages ? ; )

Avatar
ram

Community Member, 19 Posts

18 May 2010 at 10:50pm

Edited: 18/05/2010 10:52pm

Hi

Please find the url

http://doc.silverstripe.org/searchcontext

also find below help for slide pagination.

<% if Results.NotFirstPage %>
<a class="prev" href="$Results.PrevLink" title="View the previous page"> &laquo; Previous</a>
<% end_if %>

<% control Results.Pages(5) %>
<% if CurrentBool %>
<a href="#" class="current">$PageNum</a>
<% else %>
<a href="$Link" title="View page number $PageNum">$PageNum</a>
<% end_if %>
<% end_control %>

<% if Results.NotLastPage %>
<a class="next" href="$Results.NextLink" title="View the next page"> Next &raquo;</a>
<% end_if %>

Hope its helps

Regards,
Ram
http://www.agriya.com

Avatar
martimiz

Forum Moderator, 1164 Posts

19 May 2010 at 4:37am

Edited: 19/05/2010 4:51am

Instead of

<% control Results.Pages(5) %>

you could also use
<% control Results.PaginationSummary(5) %>

This would add the first and the last page to the list.

[EDIT]
Found the way to add the dots as well - all documented within the DataObjectSet class:

<% control ProductList.PaginationSummary(5) %>
	<% if CurrentBool %>
		<strong>$PageNum</strong>
	<% else %>
		<% if Link %>
			<a href="$Link" title="<% _t('GOTOPAGE', 'Go to') %> $PageNum">
				$PageNum
			</a>
		<% else %>
			...
		<% end_if %>
	<% end_if %>
<% end_control %>

Avatar
ccburns

Community Member, 74 Posts

16 June 2010 at 3:22pm

Awesome thanks @martimiz for the information. Works perfect.

Cheers,
Colin