1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-13 02:04:35 +02:00

Update for subfield labels in column headings (primarily for ListerPro)

This commit is contained in:
Ryan Cramer
2024-06-02 12:17:02 -04:00
parent 48f85faced
commit e78ada8854
2 changed files with 16 additions and 4 deletions

View File

@@ -82,7 +82,10 @@ class FieldSelectorInfo extends Wire {
// when input=select, page or checkbox, this contains the selectable options (value => label) // when input=select, page or checkbox, this contains the selectable options (value => label)
'options' => array(), 'options' => array(),
// if field has subfields, this contains array of all above, indexed by subfield name (blank if not applicable) // if field has subfields, this contains array of all above, indexed by subfield name (blank if not applicable)
'subfields' => array(), 'subfields' => array(
// same as above, plus… DB column name (if different from 'name')
// 'col' => '',
),
); );
$this->schemaToInput = array( $this->schemaToInput = array(

View File

@@ -1266,6 +1266,9 @@ class ProcessPageLister extends Process implements ConfigurableModule {
if(isset($selectorInfo['input']) && $selectorInfo['input'] === 'page') { if(isset($selectorInfo['input']) && $selectorInfo['input'] === 'page') {
if(isset($selectorInfo['subfields'][$subfield])) return true; if(isset($selectorInfo['subfields'][$subfield])) return true;
if($this->wire()->pages->loader()->isNativeColumn($subfield)) return true; if($this->wire()->pages->loader()->isNativeColumn($subfield)) return true;
} else if(!empty($selectorInfo['subfields'][$subfield]['col'])) {
// selector info indicates specific DB col that is different from 'name'
return true;
} }
return false; return false;
} }
@@ -1304,6 +1307,7 @@ class ProcessPageLister extends Process implements ConfigurableModule {
$systemLabels = $this->getSystemLabels(); $systemLabels = $this->getSystemLabels();
$tableFields = array(); $tableFields = array();
$header = array(); $header = array();
$useLabels = $this->useColumnLabels;
/** @var MarkupAdminDataTable $table */ /** @var MarkupAdminDataTable $table */
$table = $modules->get('MarkupAdminDataTable'); $table = $modules->get('MarkupAdminDataTable');
@@ -1335,18 +1339,23 @@ class ProcessPageLister extends Process implements ConfigurableModule {
if($subname) { if($subname) {
$subfield = $fields->get($subname); $subfield = $fields->get($subname);
$sublabel = $subname;
if($subfield) { if($subfield) {
$sublabel = $subfield->getLabel(); $sublabel = $subfield->getLabel();
$sublabel = str_replace($sep1, ' ', $sublabel); $sublabel = str_replace($sep1, ' ', $sublabel);
if(!$sublabel) $sublabel = $subname; if(!$sublabel) $sublabel = $subname;
$label .= $sep1 . $sublabel;
$subicon = $subfield->getIcon(true); $subicon = $subfield->getIcon(true);
if($subicon) $icon = $subicon; if($subicon) $icon = $subicon;
} else { } else if($field && $useLabels) {
$label .= $sep1 . $subname; $subinfo = $field->type->getSelectorInfo($field);
if(!empty($subinfo['subfields'][$subname]['label'])) {
$sublabel = $subinfo['subfields'][$subname]['label'];
}
} }
$label .= $sep1 . $sublabel;
if($language) { if($language) {
$label = $this->addLanguageLabel($label, $language); $label = $this->addLanguageLabel($label, $language);
} }