Homepage
Main navigation
Main content
Additional information
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
Winter CMS resources and help articles
Simple and to the point. Optimized by the community.
×
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
Edit trick
Changes will be published after manual review
Title
Give your trick a describing title. Do
not
start with «How to...».
Your trick
Keep it short and concise! Markdown is supported.
When a controller uses the ListController behavior and no filter has been defined in its config_list.yaml, this trick will allow you to dynamically create one. <br> <br> ``` Controllers\MyController::extend(function ($controller) { if (!$controller->listConfig) { // controller uses the default value $controller->addDynamicProperty('listConfig', 'config_list.yaml'); } $listConfig = $controller->makeConfig($controller->listConfig); if (!isset($listConfig->filter)) { // no filter defined in config_list.yaml, let's create one $listConfig->filter = [ 'scopes' => [ 'myScope' => [ 'type' => 'checkbox', 'label' => 'Apply My Scope', 'default' => false, 'conditions' => 'mod(id,2)', ], ], ]; } $controller->listConfig = $listConfig; }); ``` Note: if a filter already exists, use the `extendListFilterScopes()` method. ref. https://wintercms.com/docs/backend/lists#extend-filter-scopes
References
Add additional online resources to your trick
×
Name
URL
×
Name
URL
×
Name
URL
+ Add reference
Topics
If your trick fits more than one topic select multiple. Select at least one.
Backend
Plugin Development
CMS
Twig
Themes
Deployment
Tags
You can use existing tags or create new ones. Add at least one.
Submit for review
Cancel
We use cookies to measure the performance of this website. Do you want to accept these cookies?
Accept
Decline