Recent Topics

1 Feb 05, 2007 05:13    

How can display a single post in the first page and several posts in the rest of the pages for the same blog. I thought of doing it this way:


if ($blog == 2 AND $page == 1) {
    $Number of post per page == 1;
} else {
   $Number of post per page == 6;
}
  

But I don't know how to get $Number of post per page, and if $page is the correct variable.

2 Feb 08, 2007 14:48

$paged is the variable for the page number. $posts tells how many posts to put on each page. You'll need to set these in a stub file, not in the skin (_main.php) because by the time the skin loads the list of posts is already created.

3 Feb 08, 2007 19:09

I tried thisin my index.php:

if ( $paged == 1) {
$posts = 1;
} else {
$posts = 6;
}

But I get the last article in page 1 and the oldest article on page 2, the rest don't show. Is this the proper way to code it?

4 Feb 08, 2007 20:05

This should do what you want:

$posts = 6;
if ( $blog === 2 )
{
	switch ( $paged )
	{
		case 1:
			$posts = 1;
			break;
		
		default:
			// $posts = 6;
			--$paged;
			break;
	}
}

Although you will have the single post from the first page on the 2nd page, but there's no way that I know of that you can use to stop that simply.

5 Feb 08, 2007 21:39

kskhater,
It took me a bit to hammer out the math and I'm still not sure why it works, but it does.

// Customize these:
$page1 = 1;
$others = 6;

// Don't touch these:
if ( isset($_GET['paged']) and $_GET['paged'] > 1) {
  $posts = $others;
  $poststart = (($_GET['paged'] - 2) * $others + $page1 + 1 );
} else {
  $posts = $page1;
  $poststart = 1;
}


The trouble with your first attempt was that when you viewed page 2 and told it you wanted 6 posts per page, it assumed that you had 6 posts on page one, too, so it started with post #7. We can specify where to start with $poststart . I hope this works for you. You can edit the $page1 and $others variables to any combination you want.

6 Feb 09, 2007 03:17

Thanks personman,

this works perfectly.

7 Feb 09, 2007 03:56

Sorry personman, in almost works but if I specify $others = 5;

I lose the last post which is post 7.

It shows only 2 pages.


Form is loading...