1 <?php
2
3 class PageIcon extends DataObjectDecorator {
4
5 function () {
6 return array(
7 'has_one' => array(
8 'PageIcon' => 'Image',
9 ),
10 );
11 }
12
13 function updateCMSFields(FieldSet &$fields) {
14 $i = new ImageField('PageIcon', _t('PageIcon.PageIcon', 'Page Image'));
15 $i->setFolderName('PageImage');
16 $fields->insertBefore(new Tab('Icon', _t('PageIcon.Image', 'Page icon')), 'Metadata');
17 $fields->addFieldToTab("Root.Content.Icon", $i);
18 }
19
20
21 public function NestedPageIcon() {
22 $p = $this->owner;
23 while (!$p->PageIconID) {
24 if ($p->Parent()->ClassName != 'SiteTree') {
25 $p = $p->Parent();
26 } else {
27 break;
28 }
29 }
30 return ($p->hasValue('PageIcon')) ? $p->PageIcon() : false;
31 }
32 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-