I need to prescribe a condition in a chunk: if there is no background image, output the background color, otherwise display the image. Installed the plugin "if". I write this:

style="[[!If? &subject=`[[+tv.bgImage]]` &operator=`==` &operand=`empty` &then=`background-color:[[+tv.bgColor]]` &else=`background-image:url([[+tv.bgImage]])`" 

tv.bgImage and tv.bgColor are variables that are responsible for the image and background color. Result - everything after style = "is not displayed. What am I doing wrong?

    1 answer 1

    In this case, no plugins are needed, use output modifiers:

     style="[[+tv.bgImage:is=``:then=`background-color:[[+tv.bgColor]]`:else=`background-image:url([[+tv.bgImage]])`]]" 

    https://docs.modx.com/revolution/2.x/making-sites-with-modx/customizing-content/input-and-output-filters-(output-modifiers)

    • thanks, works - Diefair