core-bundle
core-bundle copied to clipboard
Add data-attributes to block_searchable
Hello,
at the moment we can add an ID or a class to block_searchable.html5. What also would be useful is to add data attributes to it like that:
<div class="<?= $this->class ?> block"<?= $this->cssID ?><?php if ($this->style): ?> style="<?= $this->style ?>"<?php endif; ?><?= $this->dataAttributes ? ' ' . $this->dataAttributes : '' ?>>
Would that be possible to add in a future release?
Bye
The problem is not so much the template itself - but you would also need to provide a unified way of being able to define arbitrary attributes in content elements and modules. Programmatically and via user input.
I would handle it exactly as css class and id properties, i.e. you can set this attributes in the backend (editor input) and also via adding to to $this->dataAttributes in a possible class inheriting from Module (as it is already for css class and id, i.e. $this->cssID).
The input itself could be done with a subpalette and a wizzard.
But the problem that i see: in most cases you would probably want those attributes not on the .block but on one of its children (a link or an image...).
Then you could override the template, no?
Then you could override the template, no?
true - but then there would still be no input for it 😏
? If we would build it like cssID as it's already implemented, we would have input. And if the data attributes should be added dynamically, the dev could do that in his module programmatically.
I dont - know how a textfield (like cssID) would be sufficient. Wouldn't you need something like this?:

Ah, this is what you meant ;-) I assumed that such a form of structural input is available. We implemented such a widget by the way (which also works in the frontend): https://github.com/heimrichhannot/contao-multi_column_editor
In the next weeks we'll migrate the module to a Contao 4 bundle.
But of course, we could also use multi column wizard.