Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

SmartyPaginate 1.6 released
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
sangprabv
Smarty Rookie


Joined: 14 Feb 2005
Posts: 13
Location: Jakarta

PostPosted: Fri Sep 04, 2009 10:01 am    Post subject: Reply with quote

I love this add on. But how to navigate to other page and carry query result? Such as http://host/index.php?step=51&query_a=1234&query_b=qwerty
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
mohrt
Administrator


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

PostPosted: Fri Sep 04, 2009 9:55 pm    Post subject: Reply with quote

Use your PHP $_SESSION to retain query info, don't pass that through the URL.
Back to top
View user's profile Send private message Visit poster's website
sangprabv
Smarty Rookie


Joined: 14 Feb 2005
Posts: 13
Location: Jakarta

PostPosted: Sat Sep 05, 2009 1:51 am    Post subject: Reply with quote

use $_SESSION? You mean create a new session to handle the query result? For each $_GET? or the whole $_REQUEST? Can you help me to provide some examples? TIA
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
mohrt
Administrator


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

PostPosted: Sun Sep 06, 2009 1:32 am    Post subject: Reply with quote

If you are using SmartyPaginate, then you must be using php sessions already. So instead of passing the query through the URL to the client and back, just keep it in the sever-side session instead. This is much more secure anyways. So:

Code:
$_SESSION['query'] = 'select * from foo';


On every subsequent pagination, $_SESSION['query'] will be there for you.
Back to top
View user's profile Send private message Visit poster's website
stot
Smarty Rookie


Joined: 13 Nov 2006
Posts: 17

PostPosted: Sat Dec 05, 2009 11:40 pm    Post subject: internal pagination data is growing Reply with quote

mohrt wrote:


2) No, the examples are just using arrays as the source data. You would normally be using SQL with query limits set.


Hi Mohrt,

rather than the sql result, I meant the pagination array that is handed over to smarty. here is a snippet of my Smarty Debug Console:

Code:

{$paginate}     Array (13)
total => 5789
first => 1
last => 15
page_current => 1
page_total => 386
size => 14
url => "/search?searchstring=creme&sort=&order="
urlvar => "next"
current_item => 1
prev_text => "prev"
next_text => "next"
limit => 15
page => Array (386)
  1 => Array (4)
    number => 1
    item_start => 1
    item_end => 15
    is_current => true
  2 => Array (4)
    number => 2
    item_start => 16
    item_end => 30
    is_current => false

+++ here are _all_ pages between 2 and 385 +++

  385 => Array (4)
    number => 385
    item_start => 5761
    item_end => 5775
    is_current => false
  386 => Array (4)
    number => 386
    item_start => 5776
    item_end => 5789
    is_current => false


The number of total results is 5789, pages 386.
A full array with page related information, such as number, start, end, current is created and handed over to smarty. This will slow down the rendering process, since all the data needed to be created and submitted to smarty. Not to mention memory usage. I have several categories with tens of thousands of entries.
Would it be possible to create only the slice of the array which is needed for display?

Any comments would be apprechiated,
thanks, stot
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


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

PostPosted: Sat Dec 05, 2009 11:46 pm    Post subject: Reply with quote

You should only pass the data that is for display (the current page). Maybe I don't understand what you're trying to do, but the whole point of the pagination and the SQL LIMIT is for getting and displaying only what you need.
Back to top
View user's profile Send private message Visit poster's website
stot
Smarty Rookie


Joined: 13 Nov 2006
Posts: 17

PostPosted: Sun Dec 06, 2009 1:27 am    Post subject: pagination internal data structures Reply with quote

mohrt wrote:
You should only pass the data that is for display (the current page). Maybe I don't understand what you're trying to do, but the whole point of the pagination and the SQL LIMIT is for getting and displaying only what you need.


Hi Mohrt,

thanks for your quick reply. I think, we talk at cross purposes.
What I mean is, that the pagination plugin calculates _all_ the page information with their number, start, end and current information as shown in the snippet in my last post. As the number of total results gets huge, also the calculation time of the pagination plugin increases. Additionally the full (and maybe huge) array will consume memory.

Maybe there is a solution to only calculate the page number, start, end, current information for those page links that are visible and clickable by the user.

Example:
total results: 30000
pages: 3000 / 10 results per page
Current page: 1

The pagination plugin calculates the page information (number, start, end, current) for all pages. The browser shows only the first page 10 links like:
page: 1 2 3 4 5 6 7 8 9 10 Next

The other page information from 11-3000 is not needed but calculated and stored in the $pagination->page array. My feeling was that the response time increased on big categories due to generating this huge array (with enabled Smarty Debug Console). The Size of the debug console showing the full array is around 1MB html code. On high traffic pages I would avoid calculating such huge datastructures, when I only need a small slice.

I hope I am not completely wrong on this track...


best regards
stot
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


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

PostPosted: Sun Dec 06, 2009 3:43 pm    Post subject: Reply with quote

I see. It should be pretty straight forward to implement, I'll take a look.
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


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

PostPosted: Sun Dec 06, 2009 4:59 pm    Post subject: Reply with quote

Are you using the $paginate variable in the template, or are you just using the functions {paginate_middle} etc?

If you are not using the $paginate variable, you can just skip assigning it and you won't see this overhead. So:

SmartyPaginate::assign($smarty);

Leave the above expression out of your code and see what you get.
Back to top
View user's profile Send private message Visit poster's website
stot
Smarty Rookie


Joined: 13 Nov 2006
Posts: 17

PostPosted: Sun Dec 06, 2009 10:43 pm    Post subject: performance measurements Reply with quote

Hi Mohrt,

thanks again for your really quick reply.

I did some performance measurements (using apache ab) and compared requests/s with pagination of 30 hits to 30000 hits. The only difference in the testscript was the SmartyPaginate::setTotal( 30) call vs. SmartyPaginate::setTotal( 30000).

Results:
30 hits: ~20 requests/s
30000 hits: ~15 requests/s

I further compared the results above to the same test script without the SmartyPaginate::assign($smarty) call. There was no difference ;-( at all
Internally the paginate->page array is generated anyways by the plugin (although not assigned to smarty).

I think the performance loss is linear, so for 30000 hits you may loose 25% of requests/s. For 3000 hits you will only loose 2,5%. This is for most applications ok. I will figure out, if there is time to provide an optimized implementation.

The other settings I used:
debug: off
compile_check: false
caching=1
4000 requests in total


Anyways, I like smarty very much! keep up your good work.

best regards
stot
Back to top
View user's profile Send private message Visit poster's website
hao
Smarty n00b


Joined: 18 Dec 2009
Posts: 1

PostPosted: Fri Dec 18, 2009 8:40 am    Post subject: Re: SmartyPaginate 1.6 released Reply with quote

mohrt wrote:
Changes since 1.5:

* fix bug in paginate_middle, link not showing when item_total
= n*limit-1 (danw, monte)
* fix NOTICE messages in paginate_middle (Temas, monte)



this link is dead. Crying or Very sad

where can i get this plugin?! and SmartyPaginateRewrite is welcome Smile


thanks
hao
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Fri Dec 18, 2009 3:00 pm    Post subject: Reply with quote

link is fixed.
Back to top
View user's profile Send private message Visit poster's website
motohead2
Smarty n00b


Joined: 31 Mar 2010
Posts: 1

PostPosted: Wed Mar 31, 2010 9:33 pm    Post subject: {paginate_middle format="page"} ??? Reply with quote

Hello,

I am successfully utilizing the SmartyPaginate plugin.

I just had a quick question about {paginate_middle} function,

I would like for each page to be listed individually by using:

{paginate_middle format="page"}

prev [1] [2] [3] next end (something like that)

BUT, I'm not sure where to put that, or where to make the change.

Here is what I have right now (in my template file)

{paginate_prev} {paginate_middle format="page"} {paginate_next}

It made sense to me, but maybe I need to make the change somewhere else.

ALSO - My page is still showing the 'groupings'
Back to top
View user's profile Send private message
weblink
Smarty Rookie


Joined: 03 Apr 2010
Posts: 12

PostPosted: Sat Apr 03, 2010 6:59 pm    Post subject: How to do URL Encrypt with SmartPaginate? Reply with quote

Hello,

I'm new to smarty and I've got problem with pagination when pass the data from one page to another. I need to encrypt the data while passing that one.

Here is my PHP code for setUrl....

Code:
 SmartyPaginate::setUrl("http://localhost/virtual/getReport.php?open_date=".opendate."&close_date=".closedate."&virtual_id=".virtual_id);



and the url displays the following Code:

Code:
http://localhost/virtual/getReport.php?open_date=05-02-2001&close_date=01-01-2009&virtual_id=5482&next=15


In this above program code, i need to encrypt or encode the Url value of opendate, closedate and virtual_id. hope this is enough information ...

Is it possible to do with SmartyPaginate?

thanks
Back to top
View user's profile Send private message
ileadu
Smarty Rookie


Joined: 31 Aug 2006
Posts: 9

PostPosted: Fri Oct 01, 2010 6:35 am    Post subject: Reply with quote

http://www.phpinsider.com/php/code/SmartyPaginate/demo/index.php?next=91
Items 91-100 of 100 displayed.

91 92 93 94 95 96 97 98 99 100

first prev [61-70][71-80][81-90][91-100] last

last link shouldn't display for hyperlink.

http://www.phpinsider.com/php/code/SmartyPaginate/demo/index.php?next=1
Items 1-10 of 100 displayed.

1 2 3 4 5 6 7 8 9 10

first [1-10][11-20][21-30][31-40] next last

first link shouldn't display for hyperlink, too.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
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