cms-niceties/src/Extensions/HtmlEditorFieldExtension.php

25 lines
728 B
PHP
Raw Normal View History

2021-06-19 21:30:03 +02:00
<?php
namespace A2nt\CMSNiceties\Extensions;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\Form;
use SilverStripe\ORM\DataExtension;
2022-05-10 13:09:06 +02:00
/**
* Class \A2nt\CMSNiceties\Extensions\HtmlEditorFieldExtension
*
* @property \A2nt\CMSNiceties\Extensions\HtmlEditorFieldExtension $owner
*/
2021-06-19 21:30:03 +02:00
class HtmlEditorFieldExtension extends DataExtension
{
public function updateMediaForm(Form $form)
{
$page_id = $_SESSION['CMSMain']['currentPage'];
$page_urlsegment = SiteTree::get()->byID($page_id)->URLSegment;
$computerUploadField = $form->Fields()->dataFieldByName('AssetUploadField');
$computerUploadField->setFolderName(sprintf("%s/images/%s", 'Uploads', $page_urlsegment));
}
}