var $vars;
// number of displayed fields
var $nbfields;
+ // the field for sorting entries
+ var $sortfield;
/* table editor for platal
* $plname : the PLname of the page, ex: admin/payments
* $table : the table to edit, ex: profile_medals
$this->pl = $plname;
$this->table = $table;
$this->idfield = $idfield;
+ $this->sortfield = $idfield;
$this->idfield_editable = $editid;
$r = XDB::iterator("SHOW COLUMNS FROM $table");
$this->vars = array();
$page->trig("Impossible de mette à jour.");
}
if ($list) {
+ // user can sort by field by clicking the title of the column
+ if ($action == 'sort' || $action == 'sortdesc') {
+ if (isset($this->vars[$id])) {
+ // add this sort order after the others (chosen by dev)
+ $this->add_sort_field($id, $action == 'sortdesc');
+ // set as sortfield to reverse sort when clicking again
+ if ($action == 'sort') {
+ $this->sortfield = $id;
+ } else {
+ $this->sortfield = '';
+ }
+ }
+ }
if (count($this->sort) > 0) {
$sort = 'ORDER BY ' . join($this->sort, ',');
}
<table class="bicol">
<tr>
- {foreach from=$t->vars item=myval}{if $myval.display}
- <th>{$myval.desc}</th>
+ {foreach from=$t->vars item=myval key=myvar}{if $myval.display}
+ <th><a href='{$t->pl}/sort{if $t->sortfield eq $myvar}desc{/if}/{$myvar}'>{$myval.desc}</a></th>
{/if}{/foreach}
{if !$hideactions}
<th>action</th>