mirror of
https://github.com/processwire/processwire.git
synced 2025-08-15 11:14:12 +02:00
Minor improvements in core MarkupFieldtype class
This commit is contained in:
@@ -58,6 +58,16 @@ class MarkupFieldtype extends WireData implements Module {
|
||||
*/
|
||||
protected $renderIsUseless = false;
|
||||
|
||||
/**
|
||||
* Properties that are potentially linkable to source page in markup
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
*/
|
||||
protected $linkableProperties = array(
|
||||
'name', 'url', 'httpUrl', 'path', 'title',
|
||||
);
|
||||
|
||||
/**
|
||||
* Construct the MarkupFieldtype
|
||||
*
|
||||
@@ -108,8 +118,8 @@ class MarkupFieldtype extends WireData implements Module {
|
||||
foreach($value as $page) {
|
||||
$v = $page->getFormatted($property);
|
||||
$v = $field->type->markupValue($page, $field, $v);
|
||||
if($page->viewable()) {
|
||||
$a[] = "<a href='$page->url'>$v</a>";
|
||||
if($this->isLinkablePageProperty($page, $property)) {
|
||||
$a[] = "<a href='$page->url'>$property: $v</a>";
|
||||
} else {
|
||||
$a[] = $v;
|
||||
}
|
||||
@@ -356,6 +366,20 @@ class MarkupFieldtype extends WireData implements Module {
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the given page property/field name one that should be linked to the source page in output?
|
||||
*
|
||||
* @param Page $page
|
||||
* @param $property
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
protected function isLinkablePageProperty(Page $page, $property) {
|
||||
if(!in_array($property, $this->linkableProperties)) return false;
|
||||
if(!$page->viewable($property)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The string value of a MarkupFieldtype is always the fully rendered field
|
||||
*
|
||||
|
Reference in New Issue
Block a user