bhofstaetter / framework-tweaks
opinionated improvements to work with the Silverstripe framework and admin
Installs: 19
Dependents: 2
Suggesters: 1
Security: 0
Stars: 0
Forks: 0
Type:silverstripe-vendormodule
pkg:composer/bhofstaetter/framework-tweaks
Requires
- php: >=8.1
- axllent/silverstripe-trailing-slash: ^2.2.5
- bummzack/sortablefile: ^2.1
- restruct/silverstripe-copybutton: ^2.0
- silverstripe/admin: ^1.0
- silverstripe/crontask: ^2.5
- silverstripe/framework: ^4.0
- symbiote/silverstripe-gridfieldextensions: ^3.4
- unclecheese/display-logic: ^2.0
This package is auto-updated.
Last update: 2025-10-22 04:13:12 UTC
README
This module includes several, opinionated improvements to work with the silverstripe framework and admin
Installation
composer require bhofstaetter/framework-tweaks
Setup CronTask cronjob
* * * * * www-data /usr/bin/php /path/to/silverstripe/docroot/vendor/bin/sake dev/cron
Fields
`BooleanDropdownField::create($name, $title, $defaultVal, $trueLabel, $falseLabel)``NoticeField::create($name, $content, $hidden, $severity, $fieldGroupTitle)`
UI
- Fontawesome 6 icons for menu and SiteTree. To use FA Pro switch out
`SilverStripe\Admin\LeftAndMain.custom_requirements_css.fontawesome` - CMS preview defaults to "Content"
- Remove toast messages with a click on the body
- Adds help link to clear cache in the admin area
- Remove unused/unwanted menu items through
`SilverStripe\Admin\LeftAndMain.remove_menu_items`
ExtendedManyManyList
Is a replacement for the ManyManyList class that brings some cool new features
Inside an object or data extension
`updateOnBeforeAddToManyManyList($context)``updateOnAfterAddToManyManyList($context)``updateOnBeforeRemoveFromManyManyList($context)``updateOnAfterRemoveFromManyManyList($context)`
Inside manyManyList extensions
`onBeforeAdd($context)``onAfterAdd($context)``onBeforeRemoveByID($context)``onAfterRemoveByID($context)`
$context Object
Is an ArrayData object with the following values
`item``extraFields``action``joinTable``shouldBeAdded/shouldBeRemoved``list`
DataObject
`$force_on_after_writeorforceOnAfterWrite(&$force)``$max_items_countorupdateMaxItemsCount(&$count)``$duplicate_check_conditionsorupdateDuplicateCheckConditions(&$conditions)``$summary_fields_sortingorupdateSummaryFieldsSorting(&$fields)``$grid_field_inline_fieldsorupdateGridFieldInlineFields(&$fields)``$requiredFieldsorupdateRequiredFields(&$fields)``updateCanUnlink($member = null)DO NOT USEcanUnlink` directly!`ClassNameForTemplate()``getBasicCMSFields($showDescription = false, $removeEmptySettingsTab = true)`
Required Fields
Could be a database field name (truthy value => valid), a relation name of a has_many or many_many relation (count > 0 => valid) or a callable method name of this class (truthy value => valid).
private static $required_fields = [
'Name',
'Pages' => 'Add at least one Page',
'MethodOnClass' => 'Custom Error Message',
];
GridFieldConfig_Extended
$fields->addFieldsToTab('Root.Main', [
$gf = GridField::create('RelationName', 'Relation Name', $this->RelationName()),
]);
$gc = GridFieldConfig_Extended::create($gf, 'SortOrder');
$gc->enableRelationEditor();
$gf->setConfig($gc);
`modifyEditForm(function($record, $fields, $form, $itemRequest) {...})``modifyDisplayFields(function($currentFields) {...})``enableRelationEditor()``enableMultiClass()``enableVersioning()``enableInlineEditing()``disable()``makeReadonly()`
Toolbox Class
`Toolbox::is_backend()``Toolbox::on_dev_build()``Toolbox::is_frontend()``Toolbox::generate_token(int $length = 32, string $classNameToCheck = null, string $fieldToCheck = null)``Toolbox::get_session()``Toolbox::get_logger()``Toolbox::url_add_scheme($url, $scheme = 'https://')or$UrlAddScheme($url, $scheme = 'https://')``Toolbox::formatted_string(string $string, array $pattern = null)``Toolbox::clean_phone_number($phoneNumber)or$CleanPhoneNumber($phoneNumber)`
Nice Enum Values
all values
$this->dbObject('EnumField')->niceEnumValues();
selected value
private static $summary_fields = [
'EnumField.Nice' => 'Enum',
];
put your enum translations beneath `bhofstaetter\FrameworkTweaks\DBEnumExtension\NiceEnumValues`
Misc
- Adds and changes a few german translations
- Add labels from CMS Fields to SummaryFields, Search, .. through updateFieldLabels
- Prevents validation on delete, restore, ... on DataObjects
- Use
`GridFieldConfig_Extended` for ModelAdmins - When exporting data through ModelAdmins, if present on the DataObject, the results from
`getExportFields()` will be used - Sets
`SilverStripe\View\SSViewer.rewrite_hash_linkstofalse` - Sets
`SilverStripe\View\SSViewer.global_keyto$CurrentReadingMode, $CurrentUser.ID, $CurrentLocale, $BaseHref`
Included Modules
- GridField Extensions
- Sortable UploadField
- Display Logic
- CMS Actions
- Copy Button
- CronTask
- Trailing Slash
Todo
- ExtendedHasManyList
- wrapper-field for two/three/four cols per row
- wrapper-field for two cols layout
- faFileIcon
- inherit page permissions for DataObjects
- improve ExtendedManyManyList code
- improve + clean up custom GridField buttons