diff --git a/wire/core/Page.php b/wire/core/Page.php index 06d385a8..6b083acb 100644 --- a/wire/core/Page.php +++ b/wire/core/Page.php @@ -3852,6 +3852,25 @@ class Page extends WireData implements \Countable, WireMatchable { return $this->values()->getIcon($this); } + /** + * Get label markup to use in page-list or blank to use template/page-list defaults + * + * This method enables custom page classes to override page labels in page-list. + * PLEASE NOTE: Inline markup is allowed so make sure to entity-encode any text field values. + * + * If you are looking for a hookable version, you should instead hook + * `ProcessPageListRender::getPageLabel` which receives the Page as its first argument. + * + * #pw-internal + * + * @return string + * @since 3.0.206 + * + */ + public function getPageListLabel() { + return ''; + } + /** * Return the API variable used for managing pages of this type * diff --git a/wire/modules/Process/ProcessPageList/ProcessPageList.css b/wire/modules/Process/ProcessPageList/ProcessPageList.css index fc4e5370..618867fa 100644 --- a/wire/modules/Process/ProcessPageList/ProcessPageList.css +++ b/wire/modules/Process/ProcessPageList/ProcessPageList.css @@ -60,9 +60,11 @@ padding-bottom: 3px; line-height: 1em; } +/* .PageListItem > a span + span:before { content: ', '; } +*/ /** * Style for the children label and notes diff --git a/wire/modules/Process/ProcessPageList/ProcessPageListRender.php b/wire/modules/Process/ProcessPageList/ProcessPageListRender.php index 8e400e24..fcb86c7a 100644 --- a/wire/modules/Process/ProcessPageList/ProcessPageListRender.php +++ b/wire/modules/Process/ProcessPageList/ProcessPageListRender.php @@ -300,8 +300,13 @@ abstract class ProcessPageListRender extends Wire { public function ___getPageLabel(Page $page, array $options = array()) { $sanitizer = $this->wire()->sanitizer; - - if(strpos($this->pageLabelField, '!') === 0) { + $formatLabel = true; + $label = $page->getPageListLabel(); + + if(!empty($label)) { + // label from custom page class overrides others + $formatLabel = false; + } else if(strpos($this->pageLabelField, '!') === 0) { // exclamation forces this one to be used, rather than template-specific one $label = trim(ltrim($this->pageLabelField, '!')); } else { @@ -317,20 +322,24 @@ abstract class ProcessPageListRender extends Wire { if(!empty($options['noIcon'])) $icon = ''; while(strpos($label, ' ') !== false) $label = str_replace(' ', ' ', $label); - - $bracket1 = strpos($label, '{'); - - if($bracket1 !== false && $bracket1 < strpos($label, '}')) { - // predefined format string - // adjust string so that it'll work on a single line, without the markup in it - $value = $page->getText($label, true, true); // oneLine=true, entities=true - } else { - // space delimited list of fields - $value = $this->getPageLabelDelimited($page, $label, $options); - } + + if($formatLabel) { + $bracket1 = strpos($label, '{'); - if(!strlen($value)) { - $value = $sanitizer->entities($page->getUnformatted("title|name")); + if($bracket1 !== false && $bracket1 < strpos($label, '}')) { + // predefined format string + // adjust string so that it'll work on a single line, without the markup in it + $value = $page->getText($label, true, true); // oneLine=true, entities=true + } else { + // space delimited list of fields + $value = $this->getPageLabelDelimited($page, $label, $options); + } + + if(!strlen($value)) { + $value = $sanitizer->entities($page->getUnformatted("title|name")); + } + } else { + $value = $label; } if(!empty($options['noTags']) && strpos($value, '<') !== false) {