Added readonly version of SiteTreeURLSegmentFiled, small quality of life thing when a user is looking at readonly data and wants to easily view the frontend of that page.

This commit is contained in:
Jake Bentvelzen 2016-03-15 10:48:46 +11:00
parent a8d48b51b1
commit 68694c01b7
2 changed files with 28 additions and 3 deletions

View File

@ -133,4 +133,27 @@ class SiteTreeURLSegmentField extends TextField {
return Controller::join_links($this->getURLPrefix(), $this->Value(), $this->getURLSuffix());
}
public function performReadonlyTransformation() {
$newInst = parent::performReadonlyTransformation();
$newInst->helpText = $this->helpText;
$newInst->urlPrefix = $this->urlPrefix;
$newInst->urlSuffix = $this->urlSuffix;
$newInst->defaultUrl = $this->defaultUrl;
return $newInst;
}
}
/**
* Readonly version of a site tree URL segment field
*
* @package forms
* @subpackage fields-basic
*/
class SiteTreeURLSegmentField_Readonly extends SiteTreeURLSegmentField {
protected $readonly = true;
public function performReadonlyTransformation() {
return clone $this;
}
}

View File

@ -2,9 +2,11 @@
<a class="preview" href="$URL" target="_blank">
$URL
</a>
<button type="button" class="ss-ui-button ss-ui-button-small edit">
<% _t('URLSegmentField.Edit', 'Edit') %>
</button>
<% if not $IsReadonly %>
<button type="button" class="ss-ui-button ss-ui-button-small edit">
<% _t('URLSegmentField.Edit', 'Edit') %>
</button>
<% end_if %>
</div>
<div class="edit-holder">
<input $AttributesHTML />