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

problem with smarty pagination while using objects

 
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
sriramchitta
Smarty Rookie


Joined: 14 Oct 2004
Posts: 14
Location: Hyderabad

PostPosted: Thu Oct 14, 2004 6:44 pm    Post subject: problem with smarty pagination while using objects Reply with quote

function wher i used smarty paginate in my class file:

global $gDB,$gLog;

$sql = "select store_id,store_name,cat_code from stores where mall_code='$mallcode'";
$result = $gDB->query($sql);

if(DB::isError($result))
{
$gLog->log($data->getDebugInfo()."\nin query: $sql \nfunction: getAllStoresByMallId file: StoresListSH.class.php");
return 0;
}

$numrows = $result->numRows();


if($numrows>0)
{
for($i=0;$i<$numrows;$i++)
{
$data=$result->fetchRow(DB_FETCHMODE_ASSOC);

$storelist = new StoresList();

$storelist->setStoreId($data[store_id]);
$storelist->setStoreName($data[store_name]);
$storelist->setCategoryCode($data[cat_code]);

$storelistArr[$i] = $storelist;
}
SmartyPaginate::setTotal(count($storelistArr));
return array_slice($storelistArr, SmartyPaginate::getCurrentItem()-1, SmartyPaginate::getLimit());
}
return 0;
The file where i was using smarty paginate

global $gSmarty;
SmartyPaginate::connect();
$statesh = new StateSH();

$mallsh = new MallsListSH();
$mallcode = $mallsh->getMallCodeFromMallId($_GET[malls]);

$statesh->getMetroNameFromMetroId($_GET[metro])."</a>->&".
"<a href=\"showMalls.php?state=$_GET[state]&metro=$_GET[metro]&malls=$_GET[malls]\" class=\"navLinks\">"
.$mallsh->getMallNameFromMallId($_GET[malls])."</a>";

$gSmarty->assign("state",$statesh->getStateNameFromStateId($_GET[state]));
$gSmarty->assign("metro",$statesh->getMetroNameFromMetroId($_GET[metro]));
$gSmarty->assign("mall",$mallsh->getMallNameFromMallId($_GET[malls]));

$stateArr = $statesh->getAllStates("list");
$gSmarty->assign("stateArr",$stateArr);

SmartyPaginate::setLimit(30);
$storesh = new StoresListSH();
$storedetails = $storesh->getAllStoresByMallId($mallcode);
//$gSmarty->assign("storedetails",$storedetails);
$gSmarty->assign("storedetails",$storesh->getAllStoresByMallId($mallcode));
SmartyPaginate::assign($gSmarty);
$gSmarty->display("ShowStores.tpl");
SmartyPaginate::disconnect();


Code in my Template File
<table>
<tr><td class="pageHeading">Stores in {$mall|upper}</td></tr>
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
{section name="index" loop=$storedetails}

{if $smarty.section.index.index eq "0" || $smarty.section.index.index eq "10" || $smarty.section.index.index eq "20"}
<td align="left" width="33%" valign="top">
{/if}

&&<a href="#" class="links">
{$storedetails[index]->storename}</a> &<br>

{if $smarty.section.index.index eq "9" || $smarty.section.index.index eq "19" || $smarty.section.index.index eq "29"}
</td>
{/if}

{/section}
</tr>
tr><td>Items {$paginate.first}-{$paginate.last} out of {$paginate.total} displayed.<br></td></tr>

<tr><td>{paginate_prev} {paginate_middle} {paginate_next} </td></tr>
</table>

Problem is:
The following part is missing in my template file:
prev [1-25][26-50][51-75][76-100] next

and thus i am unable to move to next page and rest of the data is not displayed.

Sad Sad Sad[/b]
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
mohrt
Administrator


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

PostPosted: Thu Oct 14, 2004 8:00 pm    Post subject: Reply with quote

Look at the value of {$paginate} in the debug console, what does it show?
Back to top
View user's profile Send private message Visit poster's website
sriramchitta
Smarty Rookie


Joined: 14 Oct 2004
Posts: 14
Location: Hyderabad

PostPosted: Fri Oct 15, 2004 11:29 am    Post subject: Reply with quote

Hi,

Thanks for replying,

The value of paginate in smarty debug control is as follows

{$paginate} Array (11)
total => 33
first => 1
last => 30
size => 29
url => /~csriram/shoppingmall/source/showMal...
urlvar => next
current_item => 1
prev_text => prev
next_text => next
limit => 30
page => Array (2)
1 => Array (4)
number => 1
item_start => 1
item_end => 30
is_current => 1
2 => Array (4)
number => 2
item_start => 31
item_end => 33
is_current =>

Please Help me Sad Sad ... I need to find the solutions for this. I am despirate
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
mohrt
Administrator


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

PostPosted: Fri Oct 15, 2004 1:35 pm    Post subject: Reply with quote

Nothing shows up when you use the {paginate_*} functions? You should see:

[1-30] [31-33] next

on the first page. Try putting some dubugging info inside the paginate functions, see what they are doing.
Back to top
View user's profile Send private message Visit poster's website
sriramchitta
Smarty Rookie


Joined: 14 Oct 2004
Posts: 14
Location: Hyderabad

PostPosted: Fri Oct 15, 2004 4:39 pm    Post subject: Reply with quote

Hi,

Thanks for replying ...

I tried all the ways and debuged the code. and i found that the code which is given as example in site. Is also not working for me. May be there is something wrong in the build that i have downloaded. So, if you have a copy of smarty paginate source with you which is working. Please can you mail me that source.

My mail id is sriram_chitta@yahoo.com. Please mail me the source which is working for you. I will be so thankful to you. Surprised

Thanks Smile Razz
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
mohrt
Administrator


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

PostPosted: Fri Oct 15, 2004 5:49 pm    Post subject: Reply with quote

There shouldn't be anything wrong with the latest build, does the demo that comes with it work?

You can also grab the latest CVS, but that is the same as the current release at the moment.
Back to top
View user's profile Send private message Visit poster's website
sriramchitta
Smarty Rookie


Joined: 14 Oct 2004
Posts: 14
Location: Hyderabad

PostPosted: Sun Oct 17, 2004 4:32 am    Post subject: Thank You Reply with quote

hello Monte,

Thanks for replying .. I found the problem and solved ... i was using old smarty source ... as soon as i started to use new smarty source(2.6), it started to work.

sorry for troubling you .... and thanks for your support .... Smile

bye
Sriram Chitta
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
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