Welcome Guest, Not a member yet? Register   Sign In
Pagination: Auto split Article/Post into multiple pages
#2

[eluser]PhireGuys[/eluser]
So running you through the above code, you'll see I called the standard paginate library, but then I made sure my library was more than a certain length (12000 characters in my case).

Code:
if (strlen($data['post']->article) > 12000)

If it was over that length, I wanted to do pagination, if it wasn't, no pagination was done.

The next thing was to make sure an article didn't end up with a last page that had just a few sentences on it. To do that, you'll see I used my getremainder function and you can see it in the above code. You can change the tested lengths to whatever makes sense for your site. I just tested 8000, 7000 and 10000 characters, you can test more or change these values. I wanted them >= .2 because .2 was a decent length for an individual page, in terms of characters.

The last thing that was important was to cut up my article to only show what was supposed to be shown for the given page. That is the last chunk of the code and uses my functiion substrws.

For visual, I added in final code to use my last_page function in pagination.php to put text indicating multiple pages on all pages except the last one.

I hope this helps anything looking to try this out. This seems like a lot of code, but it is pretty simple. You can copy and page everything except the last block which you'll need to customize slightly.

Take care Smile

Edit: Since everyone likes pictures, this is it implemented on a site I'm developing. Of course I made my pagination links pretty, you'll need to do that yourself.


Messages In This Thread
Pagination: Auto split Article/Post into multiple pages - by El Forum - 07-09-2010, 08:23 AM
Pagination: Auto split Article/Post into multiple pages - by El Forum - 07-09-2010, 08:25 AM
Pagination: Auto split Article/Post into multiple pages - by El Forum - 07-12-2010, 04:52 AM
Pagination: Auto split Article/Post into multiple pages - by El Forum - 07-12-2010, 07:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB