Skip to content

Commit

Permalink
Updated so all objects receive the search settings
Browse files Browse the repository at this point in the history
SiteTree objects will have it added to their Settings tab. DataObjects will have it added to their main tab
  • Loading branch information
aletail committed May 30, 2024
1 parent 7a86d48 commit 6cb4926
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/SearchableExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use SilverStripe\Forms\Tab;
use SilverStripe\Forms\TabSet;
use SilverStripe\Core\ClassInfo;
use SilverStripe\ORM\DataObject;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\FieldGroup;
Expand Down Expand Up @@ -41,7 +42,21 @@ class SearchableExtension extends DataExtension
"getSearchableTitle" => "Text",
"getSearchableSummary" => 'HTMLText',
];

/**
* updateCMSFields
* Adds the SearchTerms GridField to the CMS tab
* This should only be applied to Data objects
*
* @param FieldList $fields
* @return void
**/
public function updateCMSFields(FieldList $fields)
{
if (DataObject::getSchema()->baseDataClass($this->owner->ClassName) != "SilverStripe\CMS\Model\SiteTree") {
$this->addSearchSettingFields($fields);
}
parent::updateCMSFields($fields);
}
/**
* updateSettingsFields
* Adds the SearchTerms GridField to the settings tab
Expand All @@ -51,6 +66,13 @@ class SearchableExtension extends DataExtension
* @return void
**/
public function updateSettingsFields(FieldList $fields)
{
if (DataObject::getSchema()->baseDataClass($this->owner->ClassName) == "SilverStripe\CMS\Model\SiteTree") {
$this->addSearchSettingFields($fields);
}
}

public function addSearchSettingFields(FieldList &$fields)
{
$fields->addFieldToTab('Root', new TabSet('Search', new Tab('Main')));

Expand Down

0 comments on commit 6cb4926

Please sign in to comment.