1 (edited by 2008-08-24 15:40:37)

Topic: [HACK] Split up Articles

Name: Span An Article over pages
Author: John/Will
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: have pagination for long articles. so 1 article can be split into a next.
Useful in lengthy articles or tutorials to control amount of information displayed at a time.
Instructions:
Adding pagination to news articles (multiple pages)
MAKE A BACKUP COPY OF SHOWS.INC.PHP in your INC folder before you begin doing this hack! .. just in case you make a mistake somewhere along the lines.

First off, access shows.inc.php and comment out or completely remove line 227, which by my calculations is:

$output = str_replace("{full-story}", $news_arr[4], $output);

Then replace it with:

$page_array = explode("[pagebreak]", $news_arr[4]);
$pagination = "";
if($page_num == ''){ $page_num = 1; }
if ( count($page_array) > 1){
if($page_num != 1){ $less=$page_num-1; $pagination .= "[url=subaction=showcomments&id=$news_arr[0]&archive=$archive&start_from=$my_start_from&ucat=$news_arr[6]&$user_query&page_num=$less>«</a> ]$for_to = count($page_array);
for ($i=1; $i<=$for_to; $i++){
if ($i == $page_num){ $pagination .= $i; }
else{ $pagination .= " [url=subaction=showcomments&id=$news_arr[0]&archive=$archive&start_from=$my_start_from&ucat=$news_arr[6]&$user_query&page_num=$i]»[/url] ]$output = str_replace("{full-story}", $page_array[$page_num-1]."
".$pagination."
", $output);
}
else{ $output = str_replace("{full-story}", $page_array[0], $output); }

So now if you want to add another page, simply add [pagebreak] and the code will do the rest.

ALSO!!!
Remove all aspects of "showcomments" and replace with "showfull" if you dont want comments to appear with every split section of an article you write.

ABOVE!!
If you find >> or << these are your "Next" and "Previous" links....You can change them accordingly!

FIND!!
$pagination = ""; and replace with
$pagination = "<div align=center>Go to Page
";
this makes a text appear at the bottom of each split article with "Go to Page" a line break and then the numbers below! it also centers the "Go to Page" !

Remember to add </div> on this line:

<a href=?subaction=showcomments&id=$news_arr[0]&archive=$archive&start_from=$my_start_from&ucat=$news_arr[6]&$user_query&page_num=$more>»HERE</div>HERE[/url]


by Adding pagination to news articles (multiple pages) something this must be done first:

Open shows.inc.php and at line 5 and 6 you'll see parts of code like this:

array("start_from", "archive", "subaction", "id", "ucat")

and at the both you must add "page_num", like this:

array("page_num", "start_from", "archive", "subaction", "id", "ucat")

so the line 5 and 6 should look finally like this:

$user_query = cute_query_string($QUERY_STRING, array("page_num",  "start_from", "archive", "subaction", "id", "ucat"));
$user_post_query = cute_query_string($QUERY_STRING, array("page_num","start_from", "archive", "subaction", "id", "ucat"), "post");

You should be good from here on in... Please read and understand this before attempting this hack... Having to explain it in full takes a good bit of typing.