More control for element exporter types #18654
Unanswered
MoritzLost
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I often run into problems when creating custom element exporter types, because the interface is pretty limited and mostly geared towards formattable exports.
Here are some improvements I'd like to see.
Support for dynamic filenames
The
getFilename()function doesn't take any arguments, and is also called byElementIndexesController::actionExport()before theexport()function. This means you can pretty much only use a hardcoded filename.What I would like to have is the ability to set the filename dynamically based on the exported elements. This would require the function to accept the
$queryparameter with the element query that is also passed toexport(). That's a breaking change, so difficult to introduce. Maybe this could be solved with a second interface that new exporters can implement, with asetQuery()method that is always called first? Or maybe there's a better solution.One use-case is the following: I need to export one file per entry. If only one entry is selected, I want to return that file as-is. If multiple entries are selected, I want to return a ZIP archive with all the files. But that means I need to use a different filename (
zipor something else for an individual entry). This isn't possible at the momentAutomatic ZIP archives
Building on the example above, a very common case is that I need to export one file per element. So I want to either return this file directly if a single element is selected, or send multiple files in a ZIP archive. It would be super useful if this could be done automatically so I don't need to manually create and return the ZIP file. This would also require the dynamic filename as mentioned above. Maybe both could be rolled into a second interface for "archivable" exports?
Limit custom exporters to specific entry types
Most of the time, my custom exporters aren't completely generic, but only intended for one specific entry type. Right now, we can only limit exporters to a specific element type, like
Entry, by attaching it to that class. But there's no way to prevent the export option from showing up in every entry source. The only solution is to throw an exception if an unexpected entry type is returned by the$querywithinexport(), but of course that's not a great solution.Beta Was this translation helpful? Give feedback.
All reactions