MODX Community

Adding/removing video tag attribute

Hi Folks

All I’m trying to do is to have two radio buttons:
One that shows ‘ON’
One that shows ‘OFF’
The ‘ON’ will inject the ‘loop’ attribute into an html5 video tag.
The ‘OFF’ will remove it.

ie
<video width=“100%” controls autoplay muted poster loop>

(sorry, unable to get the whole of the tag contents to display here, but the important opening tag has)

‘ON’ should be the default.
And when displaying the aggregated grid, under the heading of ‘LOOP’, the user should only see ‘ON’ or ‘OFF’…
and not the names of chunks or empty quotes/back ticks etc.

I’ve been searching and wrestling with various combination of approaches to other similar/dissimilar problems, but without success.
It appears a simple issue but has obviously proved anything but.

Many thanks
Chris

My setup:
Mac High Sierra 10.13.6
PHP 7.4.2
MySql 5.7.26

A Template Variable (TV) of type option should be what you want.
https://docs.modx.com/current/en/building-sites/elements/template-variables/input-types#radio-options-option