rownum() table()
A row counter column that continues across pages (row 21 on page 2 of 20).
table()->rownum($extra = [])Опції
| Опція | Значення |
|---|---|
desc | Header; default empty. |
Приклад
Not run here: without
yf_table2::$FUNC_NOT_DATA_LOADER rownum() registers its counter as a custom_fields loader, whose answer table2 runs as SQL, so every render logs an SQL error (known bug, see the notes).Код
$rows = [];
foreach (['Kyiv', 'Lviv', 'Odesa', 'Dnipro', 'Kharkiv'] as $i => $city) {
$rows[$i + 10] = ['id' => $i + 10, 'city' => $city];
}
return table($rows, ['no_pages' => 1])
->rownum(['desc' => '#'])
->text('city');Примітки
- Known bug, fixed behind a flag: rownum() is built on
func()with a callback as the first argument, which table2 by default also calls as acustom_fieldsloader: that call counts the first row (the numbers start at 2) and its number is run as SQL (an SQL syntax error in the log). - Turn on
yf_table2::$FUNC_NOT_DATA_LOADER($PROJECT_CONF['table2']['FUNC_NOT_DATA_LOADER'] = true, Settings / Widget fixes; the 4.0 default) and rownum() counts from 1 without SQL. Without it, number rows with a named func() column and your own counter.
Див. також: table/func