pagination problem $app->getUserStateFromRequest not parsing - Joomla! Forum - community, help and support
i'm trying pagination work in component. looked @ doc:
http://docs.joomla.org/using_jpaginatio ... _component
and tried basic code:
(which has missing bracket)
it show pagination page reloads when clicked. hidden form element parse 'limitstart' on page , form nicely submitted, 'limitstart' not available with:
or
(yes hidden field option in form)
i puzzled code other components equally not mcv-modelled mine. checked artforms, kunena , sobi2. seem bumb same problem each time, no matter code use:
limitstart, limit , levellimit never parsed.
http://docs.joomla.org/using_jpaginatio ... _component
and tried basic code:
(which has missing bracket)
code: select all
$db =& jfactory::getdbo();
$app =& jfactory::getapplication();
$lim = $mainframe->getuserstatefromrequest("$option.limit", 'limit', 14, 'int'); //i guess getuserstatefromrequest session or different reasons
$lim0 = jrequest::getvar('limitstart', 0, '', 'int');
$db->setquery('select sql_calc_found_rows title jos_content ',$lim0, $lim);
$rl=&$db->loadassoclist();
if (empty($rl)) {$app->enqueuemessage($db->geterrormsg(),'error'); return;}
else {
////here beauty starts
$db->setquery('select found_rows();'); //no reloading query! asking total without limit
jimport('joomla.html.pagination');
$pagenav = new jpagination( $db->loadresult(), $lim0, $lim );
foreach($rl $r) {
//your display code here
}
}
echo $pagenav->getlistfooter( ); //displays nice footer
it show pagination page reloads when clicked. hidden form element parse 'limitstart' on page , form nicely submitted, 'limitstart' not available with:
code: select all
$lim = $mainframe->getuserstatefromrequest("$option.limit", 'limit', 14, 'int');
or
code: select all
$limitstart = $app->getuserstatefromrequest("{$option}.limitstart", 'limitstart', 0, 'int');
(yes hidden field option in form)
i puzzled code other components equally not mcv-modelled mine. checked artforms, kunena , sobi2. seem bumb same problem each time, no matter code use:
limitstart, limit , levellimit never parsed.
code: select all
$test = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
$option = 'com_mycomp';
$total = count($test);
$app =& jfactory::getapplication();
$limit = $app->getuserstatefromrequest("global.list.limit", 'limit', $app->getcfg('list_limit'), 'int');
$limitstart = $app->getuserstatefromrequest("{$option}.limitstart", 'limitstart', 0, 'int');
$levellimit = $app->getuserstatefromrequest("{$option}.limit", 'levellimit', 10, 'int');
echo 'total='.$total.'<br />';//good
echo 'limit='.$limit.'<br />';//does not parse
echo 'limitstart='.$limitstart.'<br />';//does not parse
echo 'levellimit='.$levellimit.'<br />';//does not parse
echo 'option='.$option.'<br />';//good
if ($limitstart >= $total) $limitstart = 0;
jimport('joomla.html.pagination');
$pagenav = new jpagination( $total, $limitstart, $limit );
echo $pagenav->getlistfooter();
did set hidden input task( having same value task generates list ) in adminform?
Comments
Post a Comment