marcoarment/secondcrack — Issue #13: Pagination
Author: jeremygibbs
Created: 2012-01-30 09:49:12+00:00
State: open

#### Problem
While testing the new pagination, I discovered that, for pages `index-2` and beyond, the "previous_page_url" and "next_page_url" values in `$content` were wrong. The actual index pages were fine, just not the array values for their link. I believe that I tracked down the culprit:

In `engine/Post.php` the function `write_index_sequence` sets a destination uri for the paginated index files:

```php
$dest_uri = substring_after(substring_before($dest_path, '.', true), Updater::$dest_path);
```

The problem is that when `write_index_sequence` is called in `engine/Updater.php`, it is passed a destination url like so:

```php
Post::write_index_sequence( self::$dest_path . "/index", ....
```

Given a destination url in this form (`/some/path/index`), the `$dest_uri` construction fails because there is no '.' in the name.

#### The Fix
I changed that construction in `engine/Post.php` to the following and it seems to be working:

```php
$dest_uri = substring_after(substring_after($dest_path, '/', true), Updater::$dest_path);
```

#### Usage
Then to get the pagination working on the front page, simply set `public static $frontpage_paginate = true;` in `engine/Updater.php`. Then add the following to your `main.php` template file:

```php

Newer Posts >>"; ?>

<< Older Posts"; ?>

```

I'm sorry not to do a pull request, but I made a mess of my local repo and I am new enough to git that I was afraid of messing things up. Plus, it was only one line.