Page 1 of 1

Paging a long post

Posted: Sat Dec 04, 2004 10:46 pm
by gspatel
Is there a way to break up a long post (about 2000 words) into pages with a navigation bar at the top/bottom of each page? Ideally, it should show something like this:

All Pages | Page 1 | Page 2 | Page 3

etc.

MT does this very well with a plugin, and both WP and b2Evolution allow it with a simple <!--nextpage--> tag embedded in the post.

Appreciate any help.

Re: Paging a long post

Posted: Sun Dec 05, 2004 10:59 pm
by garvinhicking
We currently do not have such a plugin nor do I know of somebody who wrote it.

But it definitely is easy to achieve with our plugin API system. We have event hooks, and one for a 'entry_display' hook. One could create a plugin which operates on the full entry text and only shows X chars of that, and then embeds a link with GET variables to Page 2, 3, 4 and so on. Depending on the currently chosen page the appropriate entry portion would be displayed.

I could hack away such a plugin in maybe 30 minutes...are you experienced with PHP? Then you could do it by yourself...if not, just raise a hand and I will see to get it done during this week.

Regards,
Garvin.

Re: Paging a long post

Posted: Mon Dec 06, 2004 4:19 am
by gspatel
garvinhicking wrote: I could hack away such a plugin in maybe 30 minutes...are you experienced with PHP? Then you could do it by yourself...if not, just raise a hand and I will see to get it done during this week.

Regards,
Garvin.
Hi Gavin

Many thanks for the quick reply and the offer of help! I don't actually have the kind of PHP skills this would need (I'm a lawyer!!! g :twisted: ). Would greatly appreciate your help on this.

BTW, MT has a nifty one where it allows you to define where you want the breaks to occur -- after x number of words/paras/lines or where you physicaly specify a break. WP and B2evolution, AFAIK, require you to place a <!--nextpage--> tag, and there is a plugin that allows an over-ride of this when you want to see the full, unpaged post.

Thanks again.

Regards,

Gautam

Posted: Mon Dec 06, 2004 4:20 am
by gspatel
My apologies for the typo, that should read Garvin, not Gavin. No offence intended.

Posted: Mon Dec 06, 2004 1:54 pm
by garvinhicking
No problem about misspelling; I'm not that easily offendable ;-)

About your plugin - I just created it successfully, you can download it here: http://cvs.sourceforge.net/viewcvs.py/p ... ntrysplit/

It also offers splitting by length or by manual placing of the characters. I only chose to split by characters and not paragraphs, because I think that should suffice.

To make the plugin work in 0.7 serendipity versions (this one was developed for our CVS version), you need to add this function to the file (copy + paste it to the top of the file):

Code: Select all

function serendipity_currentURL() {
    global $serendipity;

    // All that URL getting humpty-dumpty is necessary to allow a user to change the template in the
    // articles view. POSTing data to that page only works with mod_rewrite and not the ErrorDocument
    // redirection, so we need to generate the ErrorDocument-URI here.

    $uri = parse_url($_SERVER['REQUEST_URI']);
    $qst = '';
    if (!empty($uri['query'])) {
        $qst = '&' . str_replace('&', '&', $uri['query']);
    }
    $uri['path'] = str_replace($serendipity['serendipityHTTPPath'], '', $uri['path']);
    $url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?' . $uri['path'] . $qst;
    $url = str_replace($serendipity['indexFile'] . '&', '', $url); // Kill possible looped repitions which could occur

    return $url;
}
Please tell me if the plugin works out for you!

Regards,
Garvin

Posted: Mon Dec 06, 2004 4:52 pm
by gspatel
Perfecto! Thanks so much!!

Posted: Tue Dec 07, 2004 12:26 pm
by gspatel
garvinhicking wrote: To make the plugin work in 0.7 serendipity versions (this one was developed for our CVS version), you need to add this function to the file (copy + paste it to the top of the file):
Sorry to be such a dolt -- but which file?

Posted: Tue Dec 07, 2004 5:55 pm
by garvinhicking
Sorry to be such a dolt -- but which file?
To the plugin file itself :-) (that one: http://cvs.sourceforge.net/viewcvs.py/p ... ntrysplit/)