Drupal 7 theme_table pagination sort
function deductible_menu_page($content = NULL, $arg1 = NULL, $arg2 = NULL){
/*$tablesort = tablesort_sql($header);
$result = pager_query($sql . $tablesort, $limit);
$rows = array();
// Then you can pass the data to the theme functions
$output .= theme('table', $header, $rows);
$output .= theme('pager', NULL, $limit, 0);
*/
$headervariable = array(
array('data' => t('Carrier'), 'field' => 'carrier_name', 'sort' => 'asc'),
array('data' => t('Manufacture'), 'field' => 'manufacture_name', 'sort' => 'asc'),
array('data' => t('Model'), 'field' => 'model_name', 'sort' => 'asc'),
array('data' => t('Tier'), 'field' => 'tier_name', 'sort' => 'asc'),
t('Delete'),t('Update'));
//$result = db_query("SELECT deductible_id,carrier_name,manufacture_name,model_name,tier_name FROM {drup_deductible}");
$entries_per_page=3;
$select = db_select('drup_deductible', 'pv')->extend('PagerDefault')->extend('TableSort');
$result = $select
->fields('pv', array('deductible_id','carrier_name', 'manufacture_name', 'model_name', 'tier_name'))
->limit($entries_per_page)
->orderByHeader($headervariable)
->execute();
$listitems=array();
$bigitems = array();
foreach ($result as $item) {
watchdog('Deductibe', 'hi', array(), WATCHDOG_DEBUG);
$listitems=array($item->carrier_name,
$item->manufacture_name,
$item->model_name,
$item->tier_name,
l('Delete','deductible/deductible/delete/'.$item->deductible_id),
l('Update','deductible/deductible/update/'.$item->deductible_id)
);
$bigitems[]=$listitems;
}
// return print_r($bigitems);
if (count($listitems) == 0)
$make[] = array("No Models Entered Yet");
else{
watchdog('Deductibe', 'a', array(), WATCHDOG_DEBUG);
}
$link_to_add_form = l('Add More Deductible','deductible/add_deductible');
$variable=array(
'header' => $headervariable,
'rows' => $bigitems,
'attributes' => array(),
'caption' => NULL,
'colgroups' => NULL,
'sticky' => NULL,
'empty' => NULL,
);
// return print_r($items);
$output= '<div id="car">'.theme_table($variable).'<br/>'.$link_to_add_form.'</div>';
$output .= theme('pager');
$output .= theme('sort');
return $output;
}
If yοu want to take a good deal from this ρaragraph then you have to
ReplyDeleteapply ѕuсh techniques tο уour won web sitе.
Alѕo visit my ѕite non profit credit card debt relief