Jump to content

Recommended Posts

Hi!

 

Im using the community e107 and want to hack one of their scripts. The script lists the content in alphabetic order.

 

I would like to have max 10 results per page and then paginating with next and previous buttons.

 

Something like this:

 

< prev 1 2 3 … 9 10 11 next >

 

How do I make this?

 

Theres a shortcode in the e107 that is called NEXTPREV

 

Heres an codeexample for this that Ive gotten from this page:

http://wiki.e107.org/?title=Shortcodes:Frontend:NEXTPREV

 

 

Shortcodes:Frontend:NEXTPREV
From e107 Wiki
This code is used to generate the next/previous buttons often found on pages that contain long listings from the database. The following example, will display 30 rows from the database on each page. 
  $from = ($_GET['frm']) ? $_GET['frm'] : 0;
  $view = 30;

  $total = $sql -> db_Select("download", "*", "download_author='$usernm'");
  $sql -> db_Select("download", "*", "download_author='$usernm' LIMIT $from,$view");
  while($row = $sql-> db_Fetch()){
     $text .= "text-here".$row['fieldname'];
   }

$parms = $total_items.",".$view.",".$from.",".e_SELF.'?frm=[FROM]';
$text .= $tp->parseTemplate("{NEXTPREV={$parms}}");

echo $text;

 

Ive tried to insert this into my page but it need to be modified but I cant figure out how. Or have you got any other code I can use.

 

Heres the the code from the e107 file which lists the content in alphabetic order:

 

 

<?php
/*
|   This script lists content pages by alphabetical order with buttons for letters
|   Tested for v0.7.7 and it is originally adapted from v0.617:
+---------------------------------------------------------------+
*/
require_once("../../class2.php");
require_once(HEADERF);
require_once(e_HANDLER."form_handler.php");
require_once(e_HANDLER."userclass_class.php");
$lan_file = $plugindir.'languages/'.e_LANGUAGE.'/lan_toc.php';
include_once(file_exists($lan_file) ? $lan_file : $plugindir.'languages/English/lan_toc.php');

// ##### Display scrolling list of existing content pages ------------------------------------

$text = "";
// -------- SHOW FIRST LETTERS FIRSTNAMES ------------------------------------
$sql = new db;
$distinctfirstletter = $sql -> db_Select("pcontent", "DISTINCT(LEFT(content_heading,1)) as letter", "LEFT(content_parent,1)!='0' ORDER BY content_heading ASC ");
if ($distinctfirstletter != 1){
$text .= "<form method='post' action='".e_SELF."'>
                <table class='fborder' style='width:100%'>
                <tr><td colspan='2' class='forumheader'>".CONTENT_TOC_LAN_3."</td></tr>
                <tr><td colspan='2' class='forumheader3'>";
                while($row = $sql-> db_Fetch()){
                extract($row);
                        $text .= "<input class='button' style='width:20' type='submit' name='letter' value='".strtoupper($letter)."' />";
                }
                $text .= "
                <input class='button' style='width:20' type='submit' name='letter' value='".CONTENT_TOC_LAN_6."' />
                </td></tr>
                </table></form> ";
        }

        // ---------------------------------------------------------------------------

        // -------- CHECK FOR FIRST LETTER SUBMISSION --------------------------------
        $sql = new db;
        $letter=$_POST['letter'];
        if ($_POST['letter'] != "" && $_POST['letter'] != CONTENT_TOC_LAN_6 ) {
                $letter = $_POST['letter'];
                $query = "LEFT(content_parent,1)!='0' AND content_heading LIKE '".$letter."%' ORDER BY content_heading ASC";
        } else {
                        $query = "LEFT(content_parent,1)!='0' ORDER BY content_heading ASC";
                }
        // ---------------------------------------------------------------------------

        $sql2 = new db;
        $text .= "<div style='border : solid 1px #000; padding : 4px; width : auto; height : 600px; overflow : auto; '>";
        if($article_total = $sql -> db_Select("pcontent", "*", $query)){
                if($article_total < 50 || $letter || $cat){
                        $text .= "<table class='fborder' style='width:100%'>
                        <tr>
                        <td style='width:5%' class='forumheader2'> </td>
                        <td style='width:95%' class='forumheader2'>".CONTENT_TOC_LAN_2."</td>

                        </tr>";
                        while($row = $sql -> db_Fetch()){
                                extract($row);
                            if(check_class($content_class)){
                                unset($cs);
                                $delete_heading = str_replace("&#39;", "\'", $content_heading);
                                if($sql2 -> db_Select("pcontent", "content_heading", "content_id=$content_parent")){
                                        $row = $sql2 -> db_Fetch(); $cs = $row[0];
                                }
                                $text .= "<tr>
                                <td style='width:5%; text-align:center' class='forumheader3'><img src='".e_PLUGIN."content/images/content_32.png' alt='' style='border:0' /></td>
                                <td style='width:75%' class='forumheader3'><a href='".e_PLUGIN."content/content.php?content.$content_id'>$content_heading</a> </td>
                                </td>
                                </tr>";
                             }
                        }
                        $text .= "</table>";
                } else {
                        $text .= "<br /><div style='text-align:center'>".CONTENT_TOC_LAN_4."</div>";
                }
        } else {
                $text .= "<div style='text-align:center'>".CONTENT_TOC_LAN_1."</div>";
        }
        $text .= "</div>";

        $caption = "".CONTENT_TOC_LAN_5."\n<a href='".e_PLUGIN."content/content.php?'>".CONTENT_TOC_LAN_7."</a>";
        $ns -> tablerender($caption, $text);

// ##### End ---------------------------------------------------------------------------------------------------------------------------------------------------------------------

require_once(FOOTERF);

?>

 

Ive replaced this line

 

if($article_total = $sql -> db_Select("pcontent", "*", $query)){

 

into:

 

$view = 10;			
if($article_total = $sql -> db_Select("pcontent", "*", "$query LIMIT $view")){

 

to limit the displayed content to 10 only.

 

Any idea how I can insert paginating???

 

Thanks a lot

 

Perik

 

Link to comment
https://forums.phpfreaks.com/topic/53987-paginating-script-help-%E2%80%A6/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.