Paging a long post

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
gspatel
Regular
Posts: 6
Joined: Sat Dec 04, 2004 7:18 pm

Paging a long post

Post 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.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Paging a long post

Post 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.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gspatel
Regular
Posts: 6
Joined: Sat Dec 04, 2004 7:18 pm

Re: Paging a long post

Post 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
gspatel
Regular
Posts: 6
Joined: Sat Dec 04, 2004 7:18 pm

Post by gspatel »

My apologies for the typo, that should read Garvin, not Gavin. No offence intended.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gspatel
Regular
Posts: 6
Joined: Sat Dec 04, 2004 7:18 pm

Post by gspatel »

Perfecto! Thanks so much!!
gspatel
Regular
Posts: 6
Joined: Sat Dec 04, 2004 7:18 pm

Post 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?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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/)
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply