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

SmartyPaginate conflit

 
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
dolphin713
Smarty Rookie


Joined: 14 Jul 2008
Posts: 5

PostPosted: Mon Jul 14, 2008 2:06 pm    Post subject: SmartyPaginate conflit Reply with quote

Hi,
I have a problem using smartypaginate, that I canīt solve, and need your help.
The problem is due to a page with 2 tables each one having his own pagination. When I press the next page on a table, it influences
the start limit of the other table, and they are supposed to be independent.

So, I have 2 funcionts and a template( with the 2 independent tables), what Iīve done was assigning each table an ID, but it still
doesnīt works.

This is part of my code functions :
Code:

function getMyProjectTasks(...){
...
        SmartyPaginate::reset();
        SmartyPaginate::connect('projecttasks');
        SmartyPaginate::setLimit($lim,'projecttasks');
        SmartyPaginate::setTotal($num,'projecttasks');
        $start = SmartyPaginate::getCurrentIndex('projecttasks');
        $lim = SmartyPaginate::getLimit('projecttasks');

....
}


function getProjectLog(..){
-----
          SmartyPaginate::reset();
          SmartyPaginate::connect('projlog');
        SmartyPaginate::setLimit($lim,'projlog');
        SmartyPaginate::setTotal($num,'projlog');
          $start = SmartyPaginate::getCurrentIndex('projlog');
        $lim = SmartyPaginate::getLimit('projlog');
       
.....
}


In the page that invokes the template I have
Code:

SmartyPaginate::assign($template);


and in the template I have
Code:

{paginate_prev id="projecttasks"} {paginate_middle id="projecttasks"} {paginate_next id="projecttasks"}


and
Code:

{paginate_prev id="projlog"} {paginate_middle id="projlog"} {paginate_next id="projlog"}


Althought I have assigned an id to each paginated table, they are confliting with each one, I donīt know what else to do, so Iīm asking
you help.



Below is some debug data using var_dump($_SESSION['SmartyPaginate']);, before and after pressing a pagination link in table 1

BEFORE :
Code:

array
  'default' =>
    array
      'item_limit' => int 10
      'item_total' => null
      'current_item' => int 1
      'urlvar' => string 'next' (length=4)
      'url' => string '/intranet/intra_plugins/collab/manageproject.php' (length=48)
      'prev_text' => string 'prev' (length=4)
      'next_text' => string 'next' (length=4)
      'first_text' => string 'first' (length=5)
      'last_text' => string 'last' (length=4)
  'projlog' =>
    array
      'item_limit' => int 10
      'item_total' => int 127
      'current_item' => int 1
      'urlvar' => string 'next' (length=4)
      'url' => string '/intranet/intra_plugins/collab/manageproject.php' (length=48)
      'prev_text' => string 'prev' (length=4)
      'next_text' => string 'next' (length=4)
      'first_text' => string 'first' (length=5)
      'last_text' => string 'last' (length=4)
  'projecttasks' =>
    array
      'item_limit' => int 5
      'item_total' => int 8
      'current_item' => int 1
      'urlvar' => string 'next' (length=4)
      'url' => string '/intranet/intra_plugins/collab/manageproject.php' (length=48)
      'prev_text' => string 'prev' (length=4)
      'next_text' => string 'next' (length=4)
      'first_text' => string 'first' (length=5)
      'last_text' => string 'last' (length=4)


AFTER pressing the next page in the table trhat has 'projecttasks' ID


Code:

array
  'default' =>
    array
      'item_limit' => int 10
      'item_total' => null
      'current_item' => int 1
      'urlvar' => string 'next' (length=4)
      'url' => string '/intranet/intra_plugins/collab/manageproject.php' (length=48)
      'prev_text' => string 'prev' (length=4)
      'next_text' => string 'next' (length=4)
      'first_text' => string 'first' (length=5)
      'last_text' => string 'last' (length=4)
  'projlog' =>
    array
      'item_limit' => int 10
      'item_total' => int 127
      'current_item' => string '6' (length=1)
      'urlvar' => string 'next' (length=4)
      'url' => string '/intranet/intra_plugins/collab/manageproject.php' (length=48)
      'prev_text' => string 'prev' (length=4)
      'next_text' => string 'next' (length=4)
      'first_text' => string 'first' (length=5)
      'last_text' => string 'last' (length=4)
  'projecttasks' =>
    array
      'item_limit' => int 5
      'item_total' => int 8
      'current_item' => string '6' (length=1)
      'urlvar' => string 'next' (length=4)
      'url' => string '/intranet/intra_plugins/collab/manageproject.php' (length=48)
      'prev_text' => string 'prev' (length=4)
      'next_text' => string 'next' (length=4)
      'first_text' => string 'first' (length=5)
      'last_text' => string 'last' (length=4)


As you can see it changed

'projlog' =>
'current_item' => string '6' (length=1)

when I want it to remain unchanged ('current_item' => int 1)



Thanks,
Jcorreia
Back to top
View user's profile Send private message
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Mon Jul 14, 2008 2:35 pm    Post subject: Reply with quote

Try setting different urlvars for the two paginations.
Code:
SmartyPaginate::setUrlVar('nexttask', 'projecttasks');
SmartyPaginate::setUrlVar('nextlog',  'projectlog');

_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
dolphin713
Smarty Rookie


Joined: 14 Jul 2008
Posts: 5

PostPosted: Tue Jul 15, 2008 10:16 am    Post subject: Reply with quote

Thanks, I will try that.
Back to top
View user's profile Send private message
dolphin713
Smarty Rookie


Joined: 14 Jul 2008
Posts: 5

PostPosted: Wed Jul 16, 2008 9:38 am    Post subject: Reply with quote

Hi,
that did half the trick, because they don+t conflitct anymore but the current item is not updated, and stays everytime in '1', So
Code:
$start = SmartyPaginate::getCurrentIndex('projecttasks');
, is always returning '1'.


Hereīs some debug information after I press the page 2 of tasks, which will build the url "...manageproject.php?action=showproject&id=11&nexttask=6"

Code:

array
  'default' =>
    array
      'item_limit' => int 10
      'item_total' => null
      'current_item' => int 1
      'urlvar' => string 'next' (length=4)
      'url' => string '/intranet/intra_plugins/collab/manageproject.php' (length=48)
      'prev_text' => string 'prev' (length=4)
      'next_text' => string 'next' (length=4)
      'first_text' => string 'first' (length=5)
      'last_text' => string 'last' (length=4)
  'projlog' =>
    array
      'item_limit' => int 10
      'item_total' => int 128
      'current_item' => int 1
      'urlvar' => string 'nextlog' (length=7)
      'url' => string '/intranet/intra_plugins/collab/manageproject.php' (length=48)
      'prev_text' => string 'prev' (length=4)
      'next_text' => string 'next' (length=4)
      'first_text' => string 'first' (length=5)
      'last_text' => string 'last' (length=4)
  'projecttasks' =>
    array
      'item_limit' => int 5
      'item_total' => int 8
      'current_item' => int 1
      'urlvar' => string 'nexttask' (length=8)
      'url' => string '/intranet/intra_plugins/collab/manageproject.php' (length=48)
      'prev_text' => string 'prev' (length=4)
      'next_text' => string 'next' (length=4)
      'first_text' => string 'first' (length=5)
      'last_text' => string 'last' (length=4)



Another thing I don+t understand is why there is a 'default' array, when Iīm always using some ident.

What Iīm I missing ?

Thanks,
jcorreia
Back to top
View user's profile Send private message
dolphin713
Smarty Rookie


Joined: 14 Jul 2008
Posts: 5

PostPosted: Wed Jul 16, 2008 9:44 am    Post subject: Reply with quote

Hi, found out why,
I was doing
Code:
SmartyPaginate::disconnect();


everytime in a a previous page Embarassed


This problem is solved...thanks Laughing

another thing, how can I change in the paginantion links, the current page we are in to bold ?
Back to top
View user's profile Send private message
dolphin713
Smarty Rookie


Joined: 14 Jul 2008
Posts: 5

PostPosted: Wed Jul 16, 2008 9:55 am    Post subject: Reply with quote

ok, found out I have to change smarty function smarty_function_paginate_middle()

Thanks!
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
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