Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Can anybody help me?? Pagination

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
cyberchild
Smarty n00b


Joined: 22 May 2005
Posts: 3

PostPosted: Sun May 22, 2005 4:13 pm    Post subject: Can anybody help me?? Pagination Reply with quote

hi.. first sorry for my rusty english Embarassed

i have a problem by using pagination

i get these errors but i can can page through the rs..
Quote:


OK I FOUND THE FIRST ERROR. I FORGOT AN (INT)



and
Quote:

Items 13-16 out of 28 displayed. Vorher
Notice: Undefined index: format in F:\InetPub\InetPub_WebSites\cms2.carsten-hill.de\include\Smarty-2.6.9\libs\plugins\function.paginate_middle.php on line 103

Notice: Undefined variable: _ret in F:\InetPub\InetPub_WebSites\cms2.carsten-hill.de\include\Smarty-2.6.9\libs\plugins\function.paginate_middle.php on line 114

Notice: Undefined variable: _display_pages in F:\InetPub\InetPub_WebSites\cms2.carsten-hill.de\include\Smarty-2.6.9\libs\plugins\function.paginate_middle.php on line 120

Notice: Undefined index: format in F:\InetPub\InetPub_WebSites\cms2.carsten-hill.de\include\Smarty-2.6.9\libs\plugins\function.paginate_middle.php on line 103

Notice: Undefined index: format in F:\InetPub\InetPub_WebSites\cms2.carsten-hill.de\include\Smarty-2.6.9\libs\plugins\function.paginate_middle.php on line 103

Notice: Undefined index: format in F:\InetPub\InetPub_WebSites\cms2.carsten-hill.de\include\Smarty-2.6.9\libs\plugins\function.paginate_middle.php on line 103

Notice: Undefined index: format in F:\InetPub\InetPub_WebSites\cms2.carsten-hill.de\include\Smarty-2.6.9\libs\plugins\function.paginate_middle.php on line 103

Notice: Undefined index: format in F:\InetPub\InetPub_WebSites\cms2.carsten-hill.de\include\Smarty-2.6.9\libs\plugins\function.paginate_middle.php on line 103

Notice: Undefined index: format in F:\InetPub\InetPub_WebSites\cms2.carsten-hill.de\include\Smarty-2.6.9\libs\plugins\function.paginate_middle.php on line 103
[1-4][5-8][9-12][13-16][17-20][21-24][25-28] Weiter







here is my code
[php:1:3a31c011f2]
require('./inc/conf/sysconf.php'); // Benötigte Config-Datei mit allen wichtigen Steuerparametern

$smarty = new Smarty_paginationtest; // Hier wird Smarty definiert
$cache_id = $_SESSION['language'].'_'.$_SERVER['PHP_SELF'].'_'.CUR_TEMPLATE; // erzeugt eine einzigartige Cache Datei bei mehreren Sprachen

if
(!$smarty->is_cached(CUR_TEMPLATE.'/pagination-test', $cache_id)) // Prüfe ob das gefüllte Tempalte bereits im Cache ist.
{ // kein Cache gefunden, also Variablen zuweisen



SmartyPaginate::connect();
SmartyPaginate::setLimit(4);


$sql ="SELECT
".TABLE_TODO_BUGTRACKER.".todo_ID,
".TABLE_TODO_BUGTRACKER.".language_id,
".TABLE_TODO_BUGTRACKER.".todo_kategorie,
".TABLE_TODO_BUGTRACKER.".todo_user_id,
".TABLE_TODO_BUGTRACKER.".todo_group_id,
".TABLE_TODO_BUGTRACKER.".todo_prio_id,
".TABLE_TODO_BUGTRACKER.".todo_erledigt,
".TABLE_TODO_BUGTRACKER.".todo_getestet,
".TABLE_TODO_BUGTRACKER.".todo_bereich,
".TABLE_TODO_BUGTRACKER.".todo_header,
".TABLE_TODO_BUGTRACKER.".todo_text,
".TABLE_TODO_BUGTRACKER.".todo_date_creation,
".TABLE_TODO_BUGTRACKER.".todo_date_update,
".TABLE_TODO_BUGTRACKER.".todo_date_erledigt,
".TABLE_TODO_BUGTRACKER.".todo_termin
FROM
".TABLE_TODO_BUGTRACKER."
ORDER BY
".TABLE_TODO_BUGTRACKER.".todo_ID ASC
LIMIT
".SmartyPaginate::getCurrentIndex().",".SmartyPaginate::getLimit()."
";

$abfrage = xtc_db_query($sql);
$bugracker = array(); // leeres Arrayelement erzeugen
while ($data = xtc_db_fetch_array($abfrage))
{
$bugtracker[] = $data;
}
$smarty->assign("bt",$bugtracker);

$_SESSION['count'] = xtc_db_query($sql);




SmartyPaginate::setTotal($_SESSION['count']);
SmartyPaginate::assign($smarty);

} // Ende der gesamten Anweiseung/Abfrage


$smarty->display(CUR_TEMPLATE . "/pagination-test.tpl", $cache_id);
?>
[/php:1:3a31c011f2]

and here is my template

Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Unbenanntes Dokument</title>
</head>

<body>
<p>{$TPL}</p>
<p>{foreach from=$bt item=btracker} </p>
<table width="54%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#F5F5F5">
  <tr>
    <td bgcolor="#CCCCCC">{$btracker.todo_header}</td>
  </tr>
  <tr>
    <td>&</td>
  </tr>
  <tr>
    <td>{$btracker.todo_text|nl2br}</td>
  </tr>
</table>
<p>  {/foreach}
</p>
<p>&</p>
<p>  {* display pagination header *}
Items {$paginate.first}-{$paginate.last} out of {$paginate.total} displayed.


{* display pagination info *}
{paginate_prev} {paginate_middle} {paginate_next}

 
 
</body>
</html>



can anybody help me??

thanks[/code][/quote]
Back to top
View user's profile Send private message
dab
Smarty Rookie


Joined: 17 Aug 2003
Posts: 13

PostPosted: Fri Feb 29, 2008 11:16 am    Post subject: Reply with quote

those are not errors. just notices. u can go ahead and ignore them.

if you want, replace the function.paginate_middle.php with this:

Code:

<?php

/**
 * Project:     SmartyPaginate: Pagination for the Smarty Template Engine
 * File:        function.paginate_middle.php
 * Author:      Monte Ohrt <monte at newdigitalgroup dot com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @link http://www.phpinsider.com/php/code/SmartyPaginate/
 * @copyright 2001-2005 New Digital Group, Inc.
 * @author Monte Ohrt <monte at newdigitalgroup dot com>
 * @package SmartyPaginate
 * @version 1.5
 */

function smarty_function_paginate_middle($params, &$smarty) {
   
    $_id = 'default';
    $_prefix = '[';
    $_suffix = ']';
    $_link_prefix = '';
    $_link_suffix = '';
    $_page_limit = null;
    $_attrs = array();

    if (!class_exists('SmartyPaginate')) {
        $smarty->trigger_error("paginate_middle: missing SmartyPaginate class");
        return;
    }
    if (!isset($_SESSION['SmartyPaginate'])) {
        $smarty->trigger_error("paginate_middle: SmartyPaginate is not initialized, use connect() first");
        return;       
    }
       
    foreach($params as $_key => $_val) {
        switch($_key) {
            case 'id':
                if (!SmartyPaginate::isConnected($_val)) {
                    $smarty->trigger_error("paginate_middle: unknown id '$_val'");
                    return;       
                }
                $_id = $_val;
                break;
            case 'prefix':
                $_prefix = $_val;
                break;
            case 'suffix':
                $_suffix = $_val;
                break;
            case 'link_prefix':
                $_link_prefix = $_val;
                break;
            case 'link_suffix':
                $_link_suffix = $_val;
                break;
            case 'page_limit';
                $_page_limit = $_val;
                break;
            case 'format':
                break;
            default:
                $_attrs[] = $_key . '="' . $_val . '"';
                break;   
        }
    }
   
    if (!isset($_SESSION['SmartyPaginate'][$_id]['item_total'])) {
        $smarty->trigger_error("paginate_middle: total was not set");
        return;       
    }
   
    if(!isset($_page_limit) && isset($_SESSION['SmartyPaginate'][$_id]['page_limit'])) {
        $_page_limit = $_SESSION['SmartyPaginate'][$_id]['page_limit'];
    }
       
    $_url = $_SESSION['SmartyPaginate'][$_id]['url'];
   
    $_total = SmartyPaginate::getTotal($_id);
    $_curr_item = SmartyPaginate::getCurrentItem($_id);
    $_limit = SmartyPaginate::getLimit($_id);
   
    $_item = 1;
    $_page = 1;
    $_ret = "";
    $_display_pages = 0;
    $_displayed_pages = 0;
   
    $_attrs = !empty($_attrs) ? ' ' . implode(' ', $_attrs) : '';
   
    if(isset($_page_limit)) {
        // find halfway point
        $_page_limit_half = floor($_page_limit / 2);
        // determine what item/page we start with
        $_item_start = $_curr_item - $_limit * $_page_limit_half;
        if( ($_view = ceil(($_total - $_item_start) / $_limit)) < $_page_limit) {
            $_item_start -= ($_limit * ( $_page_limit - $_view ));
        }
        $_item = ($_item_start >= 1) ? $_item_start : 1;
        $_page = ceil($_item / $_limit);
    }
           
    while($_item <= $_total) {
        if(isset($params['format']) && $params['format'] == 'page') {
            $_text = $_prefix . $_page . $_suffix;           
        } else {
            $_text = $_prefix . $_item . '-';
            $_text .= ($_item + $_limit - 1 <= $_total) ? $_item + $_limit - 1 : $_total;
            $_text .= $_suffix;
        }
        if($_item != $_curr_item) {
            $_this_url = $_url;
            $_this_url .= (strpos($_url, '?') === false) ? '?' : '&';
            $_this_url .= SmartyPaginate::getUrlVar($_id) . '=' . $_item;
            $_ret .= $_link_prefix . '<a href="' . str_replace('&', '&amp;', $_this_url) . '"' . $_attrs . '>' . $_text . '</a>' . $_link_suffix;
        } else {
            $_ret .= $_link_prefix . $_text . $_link_suffix;
        }
        $_item += $_limit;
        $_page++;
        $_display_pages++;
        if(isset($_page_limit) && $_display_pages == $_page_limit)
            break;
    }
   
    return $_ret;
   
}

?>

Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP