Drupal version 6.30
以下代码API地址
https://api.drupal.org/api/drupal/includes!tablesort.inc/function/tablesort_header/6
/**
* Format a column header.
*
* If the cell in question is the column header for the current sort criterion,
* it gets special formatting. All possible sort criteria become links.
*
* @param $cell
* The cell to format.
* @param $header
* An array of column headers in the format described in theme_table().
* @param $ts
* The current table sort context as returned from tablesort_init().
* @return
* A properly formatted cell, ready for _theme_table_cell().
*/
function tablesort_header($cell, $header, $ts) {
// Special formatting for the currently sorted column header.
if (is_array($cell) && isset($cell['field'])) {
$title = t('sort by @s', array('@s' => $cell['data']));
if ($cell['data'] == $ts['name']) {
$ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc');
if (isset($cell['class'])) {
$cell['class'] .= ' active';
}
else {
$cell['class'] = 'active';
}
$image = theme('tablesort_indicator', $ts['sort']);
}
else {
// If the user clicks a different header, we want to sort ascending initially.
$ts['sort'] = 'asc';
$image = '';
}
if (!empty($ts['query_string'])) {
$ts['query_string'] = '&'. $ts['query_string'];
}
$cell['data'] = l($cell['data'] . $image, $_GET['q'], array('attributes' => array('title' => $title), 'query' => 'sort='. $ts['sort'] .'&order='. urlencode($cell['data']) . $ts['query_string'], 'html' => TRUE));
unset($cell['field'], $cell['sort']);
}
return $cell;
}
这里的
$cell['data'] = l($cell['data'] . $image, $_GET['q'],
array('attributes' => array('title' => $title), 'query' =>
'sort='. $ts['sort'] .'&order='. urlencode($cell['data']) .
$ts['query_string'], 'html' => TRUE));
'&order='. urlencode($cell['data']) .
$ts['query_string']
$cell['data']是header里面的data,而不是field。
不改核心代码的情况下解决办法
$order = trim($_GET['order']) ? trim($_GET['order']) : 'n.a';
$sort = trim($_GET['sort']) ? trim($_GET['sort']) : 'asc';
$header = array(
array('data' => t('A1'), 'field' => 'n.a', 'sort' => 'asc'),
array('data' => t('A2'), 'field' => 'n.b', 'sort' => 'asc'),
array('data' => t('A3'), 'field' => 'n.c', 'sort' => 'asc'),
array('data' => t('A4'), 'field' => 'n.d', 'sort' => 'asc'),
);
foreach ($header as $item) {
if ($order == $item['data'] || $order == $item['field']) {
$order = $item['field'];
}
}
$sql .= " ORDER BY %s %s ";
$args[] = $order;
$args[] = $sort;
订阅:
博文评论 (Atom)
上海松善实业有限公司
上海松善实业有限公司是一家集多品牌销售于一体的电线电缆骨干企业,公司成立于2016年。 公司拥有国内各大品牌:起帆、远东、上上、江南、胜华等。 主要产品有:高低压电力电缆、橡套电缆、控制电缆、架空绝缘电缆、塑胶电缆、电子计算机电缆、通讯电缆、...
-
上海松善实业有限公司是一家集多品牌销售于一体的电线电缆骨干企业,公司成立于2016年。 公司拥有国内各大品牌:起帆、远东、上上、江南、胜华等。 主要产品有:高低压电力电缆、橡套电缆、控制电缆、架空绝缘电缆、塑胶电缆、电子计算机电缆、通讯电缆、...
-
符号 C- 意思是按住 Ctrol 键 M- 意指 Meta 键 (键盘上若无Meta 键,则可以ALT ESC 键来取而代之) DEL 意指退格键 (不是 删除(Delete) key) RET 意指回车键 SPC 意指空格键...
-
Step 1: 在您的 home 底下的 .forward 檔中加入: (forward又是啥東東?) "|/usr/local/bin/procmail",以後寄給您的郵件將會先交給 procmail 程式處理。 Step 2: 在你的home底下編...
没有评论:
发表评论