| Author |
Message |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 14928 Location: Kansas
|
Posted:
Mon Sep 26, 2005 6:47 am |
|
I recently had occasion to implement page break code for a client. The instructions for doing so involve adding <!--pagebreak--> to every theme.php file. Well, I'm not one for doing repetative code so I have automated the process. It involves saving a file to the includes folder and then simply including that file in each theme.php file.
Save the following code to includes/pagebreak.php | Code: | <?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2005 by Francisco Burzi */
/* http://phpnuke.org */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/* Author : Gaylen Fraley (aka Raven) */
/* http://ravenphpscripts.com http://ravenwebhosting.com */
/* Date : 9/26/2005 */
/* Version: 1.0 */
/* */
/* As far as I know this original Page Break code was developed by Humpa*/
/* I have just modularized it for easy inclusion to any theme that uses */
/* the theme.php file and tweaked it to be W3C compliant. */
/* Usage : Save this code to includes/pagebreak.php */
/* Then include this code in any theme.php file. */
/* -- FIND -- */
/* function themearticle(blah, blah) { */
/* global $blah, $blah2; */
/* -- INSERT AFTER GLOBAL STATEMENT -- */
/* include('includes/pagebreak.php'); */
/************************************************************************/
// Begin PageBreak Code
global $page;
if (!defined("_PREVIOUS")) define("_PREVIOUS","Previous");
if (!defined("_NEXT")) define("_NEXT","Next");
$contentpages = explode( "<!--pagebreak-->", $thetext );
$pageno = count($contentpages);
if ( $page=="" || $page < 1 ) $page = 1;
if ( $page > $pageno ) $page = $pageno;
$arrayelement = (int)$page;
$arrayelement --;
if ($pageno > 1) $thetextNew .= "Page: $page/$pageno<br />";
$thetextNew .= "<p align=\"justify\">".$contentpages["$arrayelement"]."</p>";
if($page >= $pageno) $next_page = "";
else {
$next_pagenumber = $page + 1;
if ($page != 1) {
$next_page .= "- ";
}
$next_page .= "<a href=\"modules.php?name=News&file=article&sid=$sid&page=$next_pagenumber\">"._NEXT." ($next_pagenumber/$pageno)</a><a href=\"modules.php?name=News&file=article&sid=$sid&page=$next_pagenumber\"><img src=\"images/right.gif\"border=\"0\" alt=\""._NEXT."\" /></a>";
}
if($page <= 1) $previous_page = "";
else {
$previous_pagenumber = $page - 1;
$previous_page = "<a href=\"modules.php?name=News&file=article&sid=$sid&page=$previous_pagenumber\"><img src=\"images/left.gif\" border=\"0\" alt=\""._PREVIOUS."\" /></a><a href=\"modules.php?name=News&file=article&sid=$sid&page=$previous_pagenumber\">"._PREVIOUS." ($previous_pagenumber/$pageno)</a>";
}
$thetextNew .= "<br /><br /><br /><center>$previous_page $next_page</center><br /><br />";
$thetext = $thetextNew;
// End PageBreak Code
?>
|
Then, edit themes/YOUR_THEME/theme.php. Find the following code | Code: | /************************************************************/
/* Function themearticle() */
/* */
/* This function format the stories on the story page, when */
/* you click on that "Read More..." link in the home */
/************************************************************/
function themearticle ($aid, $informant, $datetime, $title, $thetext, $topic, $topicname, $topicimage, $topictext) {
global $admin, $sid, $tipath; |
After that code add the following 3 lines | Code: | // Begin PageBreak Code
@include_once("includes/pagebreak.php");
// End PageBreak Code |
That's it! Now, in the Extended Text section of Submit News panel, use <!--pagebreak--> wherever you want a page break in your text. |
|
|
|
 |
64bitguy The Mouse Is Extension Of Arm

Joined: Mar 06, 2004 Posts: 1140 Location: Manchester, NH USA
|
Posted:
Mon Sep 26, 2005 11:42 am |
|
That's a heck of an idea. I have a few articles that could really use this type of function.
Do you have a long post somewhere where this can be seen in action?
Thanks
Steph |
|
|
|
 |
Quake New Member


Joined: Feb 02, 2005 Posts: 11
|
Posted:
Mon Sep 26, 2005 11:57 am |
|
Great idea, but i also like to see a demo.
This might be cool for some other modules/mods aswell. |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 14928 Location: Kansas
|
Posted:
Mon Sep 26, 2005 12:57 pm |
|
|
|
 |
64bitguy The Mouse Is Extension Of Arm

Joined: Mar 06, 2004 Posts: 1140 Location: Manchester, NH USA
|
Posted:
Mon Sep 26, 2005 1:06 pm |
|
Sexy.
Any chance to add another option to return you to the article's first page (if you are on any other page)?
Just a thought.
Steph |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 14928 Location: Kansas
|
Posted:
Mon Sep 26, 2005 1:16 pm |
|
What I had thought about was replacing the next/previous with something like
[1 2 3 4 5 6 7] |
|
|
|
 |
Quake New Member


Joined: Feb 02, 2005 Posts: 11
|
Posted:
Tue Sep 27, 2005 4:51 am |
|
I like the result. Nice  |
|
|
|
 |
ToolBox New Member


Joined: Mar 16, 2005 Posts: 24
|
Posted:
Tue Sep 27, 2005 5:57 pm |
|
Hm... That's pretty much good.
I developed another one. LOL.
In fact, I prefer to use BB2Nuke (phpbb2) pagination style. So, Advanced Contents hack, which is under final bug test stage, has 1) new pagniation style (bb2nuke style) and categorical trees of contents with image uploading/ downloading.
But, Raven's idea is another good alternative, I am pretty sure. |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 14928 Location: Kansas
|
Posted:
Tue Sep 27, 2005 6:39 pm |
|
| ToolBox wrote: | Hm... That's pretty much good.
I developed another one. LOL.
In fact, I prefer to use BB2Nuke (phpbb2) pagination style. So, Advanced Contents hack, which is under final bug test stage, has 1) new pagniation style (bb2nuke style) and categorical trees of contents with image uploading/ downloading.
But, Raven's idea is another good alternative, I am pretty sure. |
My only response to this is that I took an already existing piece of code that MANY people use and transformed it to be able to be used much easier along with making it W3C compliant. It works with any nuke theme and requires very little in the way of installation. When I published this it was appropriately placed in the How To category. It's not really meant to solicit or to be compared to something else. The way I read your post it seems you are taking more opportunity to promote your other [yet to be released] hack. |
|
|
|
 |
ToolBox New Member


Joined: Mar 16, 2005 Posts: 24
|
Posted:
Tue Sep 27, 2005 7:09 pm |
|
Yes, you got it.
I just put my noise on this topic about pagniation.
Don't think seriously about my pagniation idea. LOL.
I just developed my own idea about more efficient way to paginate Contents. |
|
|
|
 |
chatserv The Mouse Is Extension Of Arm

Joined: May 02, 2003 Posts: 1393
|
Posted:
Tue Sep 27, 2005 7:43 pm |
|
So what relation is there in a snippet of code for articles which are handled by the News module and a Content module? Not sure i'm following this correctly. |
|
|
|
 |
|
|
|
|