Php Moodle flexible_表排序
我正在使用Php Moodle flexible_表排序,php,moodle,Php,Moodle,我正在使用Moodle 2.6,并且已经将一个表从html\u表重写为flexible\u表。我搞不清楚排序是如何工作的。 我把一切安排如下: $table = new flexible_table('Car Bookings'); $table->define_baseurl(new moodle_url("/blocks/cars/view.php")); $table->define_columns(array(
Moodle 2.6
,并且已经将一个表从html\u表
重写为flexible\u表
。我搞不清楚排序是如何工作的。
我把一切安排如下:
$table = new flexible_table('Car Bookings');
$table->define_baseurl(new moodle_url("/blocks/cars/view.php"));
$table->define_columns(array(
'carname',
'platenumber',
'pickupdate',
'tankdate',
'city',
'actions',
));
$table->define_headers(array(
'car name',
'plate number',
'pick-up date',
'tank date',
'city',
'actions',
));
$table->sortable(true, 'carname');
$table->collapsible(false);
然后,我为排序添加:
if ($table->get_sql_sort()) {
$sort = ' ORDER BY '.$table->get_sql_sort();
} else {
$sort = '';
}
表正在呈现,但排序不起作用,即标题是“排序”-我可以单击它们,但什么也没有发生。我缺少什么?您需要手动进行排序。大概是这样的:
if ($orderby = $table->get_sql_sort()) {
$sql .= ' ORDER BY ' . $orderby . ' ';
}
看看/user/index.php
中的代码,你好,Russel,他们在Moodle 2.6.11中使用htlm_表和I flexible_表,在/user/index.php
的第257行附近,它有$table=新的flexible_表('user-index-participants-'。$course->id)
Hi Russel,我在我的tableif($table->get_sql_sort()){$sort='ORDER BY.$table->get_sql_sort();}中加入了user/index.ph中的{$sort=';}
,但它仍然不会对列进行排序。我做错了什么?