Pagify
This plugin splits your page into parts of approximately x bytes in a way that paragraphs are never split.
Examples:
Installation
Download the plugin from http://get-simple.info/extend/plugin/i18n/83/ and unzip it to the plugins directory of your GetSimple installation.
To enable fancy URLs, put the following line into gsconfig.php
define('PAGIFY_SEPARATOR',';');
and add a rule like the following in the root .htaccess
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule /?([A-Za-z0-9_-]+);(\d+)/?$ index.php?id=$1&page=$2 [QSA,L]
Fancy URLs will not work on the home page.
Usage
To use it, either
- specify a tag/keyword _pagify x for your page, where x is the approximate size in bytes, or
- (1.1+) specify a tag/keyword _pagify to split the page on horizontal rules (hr) - in this case you should add the 'HorizontalRule'-Button to your CKEditor configuration - or
- call the function pagify_set_size(x) in your template.
You can also add a unit to x, e.g. 1000 or 1000b (1000 bytes), 20w (20 words),
100c (100 characters), 3p (3 paragraphs = top level tags).
To set the maximum number of page links in the page navigation, you can use the second parameter of pagify_set_size, e.g. pagify_set_size(null, 9).
To see the full content, add a parameter complete to your page's URL.
If you use get_i18n_content('myslug') or getPageContent('myslug') to include content for a sidebar or similar, make sure to surround it with pagify_off() and pagify_on():
pagify_off(); get_i18n_content('myslug'); pagify_on();
If you would rather use a custom or special field instead of a keyword, you can create a dropdown box field, e.g. named pagify with two options no and yes, and then replace in your content <?php get_page_content(); ?> with e.g. (paging every 2 paragraphs):
<?php if (return_custom_field('pagify') == 'yes') { $pageNum = isset($_GET['page']) ? @((int) $_GET['page']) - 1 : 0; echo return_pagify_content(strip_decode($content),'2p',$pageNum); } else { get_page_content(); } ?>
Customization
To change the navigation texts (e.g. "First page" instead of "|<<"), edit the respective language file(s) in /plugins/pagify/lang. The easiest way to do this is to use the Translate plugin.
To change the appearance of the navigation, add style rules like the following to your theme's CSS file:
.paging { ... } .paging span { ... } .paging span.first { ... } .paging span.previous { ... } .paging span.current { ... } .paging span.next { ... } .paging span.last { ... } .paging span.inactive { ... }
Use within other Plugins
You can use code like the following - its really easy:
... # this is the content of the news item, as it would be output to the page: $content = ...; ... # determine somehow (e.g. configuration setting), if page splitting is requested if (function_exists('return_pagify_content') && ...) { # get page number from URL, e.g. $pageNum = @$_GET['page']; # determine requested page length (e.g. configuration setting) $pageSize = ...; # what is the link to this news/blog item? Include place holder %PAGE% for page number $link = 'http://server/link/to/my/news/item?page=%PAGE%'; # split content into pages and get content for current page with page navigation $content = return_pagify_content($content, $pageSize, $pageNum, $link); ... } ...