Open aschempp opened 1 year ago
we could also have a custom abstract controller
That would make sense I think.
Additionally I’d like to get rid of the _config.php
files completely when switching to fragment controllers.
Maybe by using something similar to single file components:
{% extends "@Contao/content_element/_base.html.twig" %}
{% block content %}
{{ text }}
{% endblock %}
{% config %}
return [
'label' => ['Custom Element', ''],
'types' => ['content'],
'contentCategory' => 'texts',
'standardFields' => ['cssID', 'headline'],
'fields' => [
'text' => [
'inputType' => 'standardField',
],
],
];
{% endconfig %}
Also reminds me a bit on how Twig components work, maybe we can copy some stuff from there 🤔
Here's an idea for maybe a version 3: instead of having a definition file, I'd love to define the fields in a method of my custom controller. Something like this:
we could also have a custom abstract controller or a trait that would deserialize the data and/or pass it to the template. The advantage is that I could use any template name, including Twig namespaces and overrides, and I would still have a real controller class if I need to do more stuff with the fields config 😎