Jump to content

Pagination limit + 1


999design
 Share

Recommended Posts

Hi,

I have some pagination on my page, which is pretty bog standard.

$allChildren = $page->find('template=blog-article, limit=10, sort=-article_date');

The limit is set to 10 as I want to show them 10 articles at a time.

The articles are displayed side by side, so there is 5 rows of 2 article.

I am using infinite scroll plugin (which doesn't really matter).

However the first article is a featured article and displays full width, so this leaves me with an odd article at the end.

- - - (1) - - -

- (2) - (3) -
- (4) - (5) -
- (6) - (7) -
- (8) - (9) -

- (10)

So really I need the first page to show 11 and then on other pages for it to be 10.

- - Page 1 - -

- - - (1) - - -

- (2) - (3) -
- (4) - (5) -
- (6) - (7) -
- (8) - (9) -

- (10) (11) -

- - Page 2 - -

- (12) (13) -
- (14) (15) -
- (16) (17) -
- (18) (19) -
- (20) (21) -

- - Page 3 - -

- (22) (23) -
- (24) (25) -
- (26) (27) -
- (28) (29) -
- (30) (31) -

Is this possible? Any pointers would be much appreciated!

Thanks,

Craig

Link to comment
Share on other sites

if($input->pageNum == 1){
	$featured = $page->get('template=blog-article, sort=-article_date');
}

$rest = $page->find("template=blog-article, limit=10, sort=-article_date, id!=$featured");

// Create any pagination markup here!

if($input->pageNum == 1){
	$rest->prepend($featured);
}

// Render items

 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...