Basic if/else condition comparting TV

Hi all,

Just need to make a simple condition. But I’m stuck.


But I basically want to do is read a TV: [[*Headerclass]] in a template. if the output from the TV is " header" then HTML should be:

<div class="top-banner">
        <div class="title-wrapper"><h1>¿Porque elegir Interiorisme?</h1></div>
        <img src=" class="d-md-none top-banner-mobile" alt="">
    </div>

Otherwise, just leave it empty.

Thanks!

Welcome to the MODX forums.

I think Output Modifiers are what you are after.

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

Or a fairly short snippet with the tag where you want the output to appear:

[[!ShowHeader]]

/* ShowHeader snippet */
$tv = $modx->getTVValue('Headerclass');
return $tv == 'header'? '¿Porque elegir Interiorisme?' : "";

‘Headerclass’ can be replaced by the ID of the TV (no quotes) to speed things up slightly.

[[*Headerclass:is=`header`:then=`¿Porque elegir Interiorisme?`:else=``]]
[[*Headerclass:is=header:then=`¿Porque elegir Interiorisme?`:else=``]]

I believe

1 Like