CuteNews

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> [HACK] Split up Articles, Make an article span over many pages
John/Will
post Sep 18 2004, 11:57 AM
Post #1


CuteHack: Technician
***

Group: Support
Posts: 2,986
Joined: 3-July 04
From: Channel Islands
Member No.: 46



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:

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


Then replace it with:

CODE
$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 .= "<a href=?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$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 .= " <a href=?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query&page_num=$i>$i</a> "; }
}
if ($page_num != count($page_array)){ $more = $page_num + 1; $pagination .= "<a href=?subaction=showcomments&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query&page_num=$more>»</a> "; }
$output = str_replace("{full-story}", $page_array[$page_num-1]."<br />".$pagination."<br />", $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 <br />";
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&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query&page_num=$more>»HERE</div>HERE</a>


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:

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


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

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


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

CODE
$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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 19th May 2013 - 12:37 AM