Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's
Poll
Was this tutorial helpful to you?
Yes
100%
 100%  [ 4 ]
No
0%
 0%  [ 0 ]
Total Votes : 4


Author Message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 17086

PostPosted: Mon Sep 26, 2005 6:47 am Reply with quote

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&amp;file=article&amp;sid=$sid&amp;page=$next_pagenumber\">"._NEXT." ($next_pagenumber/$pageno)</a><a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid&amp;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&amp;file=article&amp;sid=$sid&amp;page=$previous_pagenumber\"><img src=\"images/left.gif\" border=\"0\" alt=\""._PREVIOUS."\" /></a><a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid&amp;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.
 
View user's profile Send private message
64bitguy
The Mouse Is Extension Of Arm


Joined: Mar 06, 2004
Posts: 1159
Location: Sanbornton, NH USA

PostPosted: Mon Sep 26, 2005 11:42 am Reply with quote

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

_________________
Steph Benoit Only registered users can see links on this board! Get registered or login!
1CMS, 100% Section 508 and W3C XHTML/CSS Compliant (Truly) 
View user's profile Send private message Visit poster's website
Quake
New Member
New Member


Joined: Feb 02, 2005
Posts: 12

PostPosted: Mon Sep 26, 2005 11:57 am Reply with quote

Great idea, but i also like to see a demo.
This might be cool for some other modules/mods aswell.
 
View user's profile Send private message
Raven
PostPosted: Mon Sep 26, 2005 12:57 pm Reply with quote

Only registered users can see links on this board! Get registered or login!
 
64bitguy
PostPosted: Mon Sep 26, 2005 1:06 pm Reply with quote

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
PostPosted: Mon Sep 26, 2005 1:16 pm Reply with quote

What I had thought about was replacing the next/previous with something like

[1 2 3 4 5 6 7]
 
Quake
PostPosted: Tue Sep 27, 2005 4:51 am Reply with quote

I like the result. Nice Smile
 
ToolBox
Regular
Regular


Joined: Mar 16, 2005
Posts: 74

PostPosted: Tue Sep 27, 2005 5:57 pm Reply with quote

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.
 
View user's profile Send private message
Raven
PostPosted: Tue Sep 27, 2005 6:39 pm Reply with quote

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
PostPosted: Tue Sep 27, 2005 7:09 pm Reply with quote

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
Member Emeritus


Joined: May 02, 2003
Posts: 1389
Location: Puerto Rico

PostPosted: Tue Sep 27, 2005 7:43 pm Reply with quote

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.
 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©