Closed Flynsarmy closed 8 years ago
This sounds right, except maybe the method should probably be called importExportExtendColumns
. We need to understand more of the why instead of the how. Perhaps there is a more elegant way to solve the problem, but without knowing too much about the problem it is difficult to know.
Can you submit a PR to the test plugin that outlines the problem? Test plugin for investigation
Not sure if this solves the problem completely, but I think it is starting point... Extend your controller
public function import()
{
if (Request::url() == 'example.oi') {
$this->importColumns = [
'column_name' => 'Column Label'
];
}
$this->asExtension('ImportExportController')->import();
}
This is an old topic, but I was able to extend a plugin's export columns by overwriting the config file entirely.
\Acme\MyPlugin\Controllers\MyController::extend(function($controller) {
$controller->importExportConfig = '$/acme2/mypluginextension/controllers/mycontroller/config_import_export.yaml';
});
Thanks @jeremymouton
There isn't still a clear use case for this, however, we've added some basic overrides in v2.1.11
/**
* importExportExtendExportColumns
*/
public function importExportExtendExportColumns($columns)
{
return $columns;
}
/**
* importExportExtendImportColumns
*/
public function importExportExtendImportColumns($columns)
{
return $columns;
}
Thanks @jeremymouton
There isn't still a clear use case for this, however, we've added some basic overrides in v2.1.11
/** * importExportExtendExportColumns */ public function importExportExtendExportColumns($columns) { return $columns; } /** * importExportExtendImportColumns */ public function importExportExtendImportColumns($columns) { return $columns; }
Hi @daftspunk, There is currently no way to use the function. You can't override the function in the controller consuming the behavior.
Maybe this can be implemented in the behavior.
$columns = $this->controller->importExportExtendImportColumns($columns);
What do you think?
Good catch @SebastiaanKloos - fixed in v2.1.12
Thank you!
The issue
I am using the ImportExportController behavior in my plugin however the columns to import and export must be dynamically generated at runtime based on the current backend URL. There doesn't appear to be a way to extend the list columns at runtime. See the current implementation here.
Proposal
I'd like to add a importExportExtendListColumnConfig controller method to handle this. The method name is ugly and can be changed. Here is my proposed implementation:
The
makeListColumns
method is used by both getImportDbColumns and getExportColumns so perhaps adding a$context
argument tomakeListColumns
which is then passed toimportExportExtendListColumnConfig
would be helpful too.Example Usage
In a controller implementing ImportExportController behavior:
If you're happy with this I can write up a pull request.