TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Breaking up an article into pages (http://www.talkphp.com/general/1860-breaking-up-article-into-pages.html)

danielneri 01-04-2008 03:11 PM

Breaking up an article into pages
 
I've been wondering this for a long time.

Exactly how would you go about dividing up an article or a document into separate pages dynamically?

One method I've seen around is using bbcode such as [nextpage] or something but then how would you parse it? and then how would you navigate the pages?

xenon 01-04-2008 05:32 PM

My answer is arrays. Break up your enormous piece of text after the "separators" - [nextpage] or such, and store each piece into an array entry. Unfortunately, you must do this every time the page is refreshed/changed, but you can also use temporary files or tables and pull the text from there.

danielneri 01-04-2008 05:37 PM

Hmm this seems like it would slow down a piece a lot.

You're saying that using cache files would speed things up?

I run a tutorial site and some of my tuts get a bit long so I wanna know the best way to go about splitting them up...

jayjay 01-04-2008 06:20 PM

If you're using a database backend, it's easy to work with two seperate tables: articles(id, title, date) and article_pages(id, articleid, body).

Using flat files: use a page breaker like [nextpage]. Then parse the page with a regex or use explode to get an array.

CMellor 01-04-2008 07:37 PM

This may help

danielneri 01-04-2008 08:02 PM

Ah CMellor you are simply amazing!

Thanks a ton!!!


All times are GMT. The time now is 12:12 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0