core-bundle icon indicating copy to clipboard operation
core-bundle copied to clipboard

Add data-attributes to block_searchable

Open Defcon0 opened this issue 7 years ago • 8 comments
trafficstars

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

Defcon0 avatar Apr 25 '18 09:04 Defcon0

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.

fritzmg avatar Apr 25 '18 10:04 fritzmg

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).

Defcon0 avatar Apr 25 '18 10:04 Defcon0

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...).

asaage avatar Apr 25 '18 10:04 asaage

Then you could override the template, no?

Defcon0 avatar Apr 25 '18 10:04 Defcon0

Then you could override the template, no?

true - but then there would still be no input for it 😏

asaage avatar Apr 25 '18 10:04 asaage

? 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.

Defcon0 avatar Apr 25 '18 12:04 Defcon0

I dont - know how a textfield (like cssID) would be sufficient. Wouldn't you need something like this?:

image

asaage avatar Apr 25 '18 13:04 asaage

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.

Defcon0 avatar Apr 25 '18 18:04 Defcon0