1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-12 09:44:38 +02:00

Update ProcessPageLister to recognize fields that are not sortable, such as those from FieldtypeRuntimeOnly

This commit is contained in:
Ryan Cramer
2022-04-19 11:17:33 -04:00
parent 78ae5e3f56
commit 5028dd6ad4

View File

@@ -1235,6 +1235,7 @@ class ProcessPageLister extends Process implements ConfigurableModule {
*
*/
protected function isSortableCol(Field $field, $subfield = '') {
if(!$this->isSortableField($field)) return false;
if($subfield === 'data' || empty($subfield) || $subfield === 'count') return true;
if($subfield === 'keys' || $subfield === 'xtra') return false;
$fieldtype = $field->type;
@@ -1242,6 +1243,21 @@ class ProcessPageLister extends Process implements ConfigurableModule {
return isset($schema[$subfield]);
}
/**
* Is field sortable?
*
* @param Field $field
* @return bool
* @since 3.0.199
*
*/
protected function isSortableField(Field $field) {
$table = $field->getTable();
if(empty($table)) return false;
if(!$this->wire()->database->tableExists($field->getTable())) return false;
return true;
}
/**
* Build the Lister table containing results
*
@@ -1333,6 +1349,9 @@ class ProcessPageLister extends Process implements ConfigurableModule {
if($field && !$this->isSortableCol($field, $subname)) {
$thClass = 'not_sortable';
}
} else if($field && !$this->isSortableField($field)) {
$sortKey = "<b>$name</b>";
$thClass = 'not_sortable';
} else {
$sortKey = "<b>$name</b>";
}