Winter CMS resources and help articles

Simple and to the point. Optimized by the community.

Rewriting the definition of all controller columns when extending a plugin

0
by DamsFX, last modified on March 23rd, 2023

In some cases, you may want to add or remove columns from a controller's list when extending a plugin. If there are many columns, this can be a lot of work, so it may be better to completely rewrite the definition of the columns.

In this case, you can use this snippet in your plugin boot method:

YourListController::extend(function ($controller) {
    $controller->listConfig = $controller->mergeConfig(
                $controller->listConfig, 
                [
                    'list' => '$/myAuthor/myPlugin/config/new_columns.yaml'
                ]
    );
});

⚠ Take care, this can create issues if several plugins modify the controller's list columns definition.

Discussion

0 comments

We use cookies to measure the performance of this website. Do you want to accept these cookies?