TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-04-2008, 03:11 PM   #1 (permalink)
The Contributor
 
Join Date: Dec 2007
Location: Florida
Posts: 73
Thanks: 12
danielneri is on a distinguished road
Default 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?
Send a message via AIM to danielneri
danielneri is offline  
Reply With Quote
Old 01-04-2008, 05:32 PM   #2 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

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.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
The Following 2 Users Say Thank You to xenon For This Useful Post:
codefreek (01-04-2008), danielneri (01-04-2008)
Old 01-04-2008, 05:37 PM   #3 (permalink)
The Contributor
 
Join Date: Dec 2007
Location: Florida
Posts: 73
Thanks: 12
danielneri is on a distinguished road
Default

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...
Send a message via AIM to danielneri
danielneri is offline  
Reply With Quote
Old 01-04-2008, 06:20 PM   #4 (permalink)
The Visitor
 
Join Date: Jan 2008
Posts: 1
Thanks: 0
jayjay is on a distinguished road
Default

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.
jayjay is offline  
Reply With Quote
Old 01-04-2008, 07:37 PM   #5 (permalink)
The Acquainted
Upcoming Programmer 
 
CMellor's Avatar
 
Join Date: Sep 2007
Location: Leeds, UK
Posts: 141
Thanks: 6
CMellor is on a distinguished road
Default

This may help
__________________
Not quite a n00b...
CMellor is offline  
Reply With Quote
The Following 2 Users Say Thank You to CMellor For This Useful Post:
danielneri (01-04-2008), webtuto (01-05-2008)
Old 01-04-2008, 08:02 PM   #6 (permalink)
The Contributor
 
Join Date: Dec 2007
Location: Florida
Posts: 73
Thanks: 12
danielneri is on a distinguished road
Default

Ah CMellor you are simply amazing!

Thanks a ton!!!
Send a message via AIM to danielneri
danielneri is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:28 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design