![]() |
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? |
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.
|
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... |
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. |
|
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