View previous topic :: View next topic |
Author |
Message |
sriramchitta Smarty Rookie
Joined: 14 Oct 2004 Posts: 14 Location: Hyderabad
|
Posted: Thu Oct 14, 2004 6:44 pm Post subject: problem with smarty pagination while using objects |
|
|
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.
[/b] |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Oct 14, 2004 8:00 pm Post subject: |
|
|
Look at the value of {$paginate} in the debug console, what does it show? |
|
Back to top |
|
sriramchitta Smarty Rookie
Joined: 14 Oct 2004 Posts: 14 Location: Hyderabad
|
Posted: Fri Oct 15, 2004 11:29 am Post subject: |
|
|
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 ... I need to find the solutions for this. I am despirate |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Oct 15, 2004 1:35 pm Post subject: |
|
|
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 |
|
sriramchitta Smarty Rookie
Joined: 14 Oct 2004 Posts: 14 Location: Hyderabad
|
Posted: Fri Oct 15, 2004 4:39 pm Post subject: |
|
|
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.
Thanks |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Oct 15, 2004 5:49 pm Post subject: |
|
|
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 |
|
sriramchitta Smarty Rookie
Joined: 14 Oct 2004 Posts: 14 Location: Hyderabad
|
Posted: Sun Oct 17, 2004 4:32 am Post subject: Thank You |
|
|
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 ....
bye
Sriram Chitta |
|
Back to top |
|
|