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

SmartyPaginate 1.5 Released

 
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
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Oct 06, 2005 8:43 pm    Post subject: SmartyPaginate 1.5 Released Reply with quote

Changes since 1.4:

* fix bug with last link on uneven groupings (pt2002, monte)
* fix error in paginate_middle with replacing & (Michele, monte)
* add setPageLimit()/getPageLimit() functions (monte)
* make error messages better in plugins (monte)
* fix format=page error in paginate_middle href tags (NeXXt, monte)

http://www.phpinsider.com/php/code/SmartyPaginate/
Back to top
View user's profile Send private message Visit poster's website
talo
Smarty Rookie


Joined: 18 Oct 2005
Posts: 16

PostPosted: Tue Nov 15, 2005 9:28 am    Post subject: Download in .Zip??? Reply with quote

Hi,

I was wandering if there is a Zipped form of the the plugin to download?

I get the following error: "error reading header after processing 0 entries"
trying to open it with WinZip.

Tnx,
T.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Nov 15, 2005 10:01 pm    Post subject: Reply with quote

WinZip should have no problem opening .tar.gz files?

No, there is no .zip version of it. Maybe someone can untar this and zip it for you.
Back to top
View user's profile Send private message Visit poster's website
Boby
Smarty Rookie


Joined: 21 Jan 2006
Posts: 21

PostPosted: Sat Apr 01, 2006 10:26 am    Post subject: Reply with quote

Just a question Smile

in function.paginate_middle.php you have this:
Code:
if($params['format'] == 'page') {
    $_text = $_prefix . $_page . $_suffix;
} else {
    $_text = $_prefix . $_item . '-';
    $_text .= ($_item + $_limit - 1 <= $_total) ? $_item + $_limit - 1 : $_total;
    $_text .= $_suffix;
}

Shouldn't be there a way to have this style of links?
1 2 3 [4] 5 6 7
or
1-10 11-20 21-30 31-40 [41-50] 51-60 61-70

Where in this case [4] or [41-50] is the current page. Most homepages are using this style. Probably add two more parameters like $_current_prefix and $_current_suffix.

Thank you!
Boby
_________________
My Homepage: www.frozenminds.com
Back to top
View user's profile Send private message Visit poster's website
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Tue Apr 11, 2006 4:49 pm    Post subject: Reply with quote

Code:

$_text = isset($params['text']) ? $params['text'] : SmartyPaginate::getLastText($_id);


In the plugins you test for this param after putting any passed-in param's in the $_attrs variable.

This has the odd effect of adding a text="First" param into the links.

I think that this param should be captured in the case statement

Code:

case 'text':
$_text = isset($params['text']) ? $params['text'] : SmartyPaginate::getFirstText($_id);
break;

_________________
Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template
Back to top
View user's profile Send private message Visit poster's website
Elandril
Smarty n00b


Joined: 18 Apr 2006
Posts: 2

PostPosted: Tue Apr 18, 2006 9:54 am    Post subject: Reply with quote

Firstly thanks for this awesome pluging... Very Happy
and secondly I've got a little feature request! Wink

I really like this plugin and have already used it in a number of pages, but now I've got to revamp a few of them using AJAX. So I'd like to remain using this add-on, but it would have to be changed.

I don't know if something like this has already been proposed, but could the add-on be extended to not only produce links with href and get variables, but alternatively links with href="#" and onclick="ajaxproc(pagenumber); return false;" ?
Back to top
View user's profile Send private message
cdukes
Smarty n00b


Joined: 15 May 2006
Posts: 2

PostPosted: Tue May 16, 2006 2:07 pm    Post subject: Paginate 1.5 Problem Reply with quote

I'm trying to get this working but am having trouble.

Here's my code:
Code:

     function get_db_results() {

         $_query = sprintf(
                 "SELECT SQL_CALC_FOUND_ROWS * FROM " . DBD_TABLE . " LIMIT %d,%d",
                 SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit()
                 );
         
         $_result = mysql_query($_query) || die (mysql_error("Result: $_result " . mysql_error()));
 
         
         while ($_row = mysql_fetch_array($_result, MYSQL_ASSOC)|| die ("Query: $_query <br>Result: $_result "
. mysql_error())) {
             // collect each record into $_data
             $_data[] = $_row;
         }

         // now we get the total number of records from the table
         $_query = "SELECT FOUND_ROWS()";
         $_result = mysql_query($_query) || die ("Query: $_query " . mysql_error());
         $_row = mysql_fetch_array($_result, MYSQL_ASSOC) || die ("Result: $_result " . mysql_error());

         SmartyPaginate::setTotal($_row['FOUND_ROWS']);

         return $_data;

}


Here's the result I get:
Code:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /www/cmdb/html/libs/dbd.lib.php on line 171
Query: SELECT SQL_CALC_FOUND_ROWS * FROM ciscoworks LIMIT 0,25
Result: 1


Why is there only 1 result?
If I run it manually in mysql, it works fine.
Code:

mysql> SELECT SQL_CALC_FOUND_ROWS * FROM ciscoworks LIMIT 0,25;
...snip
25 rows in set (0.01 sec)
Back to top
View user's profile Send private message AIM Address
mapletip
Smarty n00b


Joined: 22 Oct 2006
Posts: 2

PostPosted: Sun Oct 22, 2006 7:20 am    Post subject: Reply with quote

I don't know if anyone cares but there's an XSS attack in the next variable.

To fix..

Find:
Code:

function getCurrentItem($id = 'default') {


Change the body of the function to..

Code:
if (is_numeric($id)) {
           return htmlentities($_SESSION['SmartyPaginate'][$id]['current_item']);
      }else{
      //they be tryin' to hack us lawl
         $id = 'default';
         return htmlentities($_SESSION['SmartyPaginate'][$id]['current_item']);
      }


And that's it Smile[/code]
Back to top
View user's profile Send private message
conrad10781
Smarty n00b


Joined: 24 Jun 2006
Posts: 4

PostPosted: Sun Apr 15, 2007 5:54 pm    Post subject: Reply with quote

Not sure if I am the only one who is experiencing this, but here is a fix who are. I had some issues where we would be using pagination on one link ( page1.php ), people would then follow another link to another part of our site ( page2.php ), upon going back to page1.php the last page they were on, they are brought to the last page of the pagination they were on.. IE page 6 say, instead of being refreshed back to page 1. If anyone else comes across this, here is what we did

in SmartyPaginate.class.php ( starting ~ 223 ), You can obviously adjust ['next'] to whatever you use , or there may even be a class object you can use to make it universal

More or less just replace the 2 functions ( getCurrentItem & getCurrentIndex )
Code:

     function getCurrentItem($id = 'default') {
       /**
       * fix by RCS
       * initial page landing would show page 3 if that is where they were last
       */
       if(!isset($_GET['next'])){
           return "1";   
       }else{
          return $_SESSION['SmartyPaginate'][$id]['current_item'];
       }
           
    }   

    /**
     * get the current item index
     *
     * @param string $id the pagination id
     */
    function getCurrentIndex($id = 'default') {
       /**
       * fix by RCS
       * initial page landing would show page 3 if that is where they were last
       */
       if(!isset($_GET['next'])){
           return "0";   
       }else{
           return $_SESSION['SmartyPaginate'][$id]['current_item'] - 1;
       }
    }   


NOTE: This was my fault, there was nothing wrong with the smarty code, the code I was using around my reset call, which was caused by a new mod_rewrite rule
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