# Output modifiers in field template

**URL:** <https://forum.modmore.com/t/output-modifiers-in-field-template/2352>\
**Category:** ContentBlocks\
**Created:** [May 3, 2022, 3:24pm UTC](https://forum.modmore.com/t/output-modifiers-in-field-template/2352 "2022-05-03T15:24:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![inreti](https://forum.modmore.com/letter_avatar_proxy/v4/letter/i/f0a364/32.png) [@inreti](https://forum.modmore.com/u/inreti)\
**Post date:** [May 3, 2022, 3:24pm UTC](https://forum.modmore.com/t/output-modifiers-in-field-template/2352/1 "2022-05-03T15:24:31Z")

</div>

Hi! Can’t get this output modifiers in a Repeater element to work.  
If there is a link set, an a-tag with target should be wrapped, if it’s empty an div tag.

```
[[+url:!empty=`
    <a href='[[+url]]' target='_blank' class='logo cell medium-3 ratio1-1' data-equalizer-watch>
        [[+logo]]
    </a>
`]]
[[+url:empty=`
    <div class='logo cell small-6 medium-3 Xratio1-1' data-equalizer-watch>
        [[+logo]]
    </div>
`]]

```

Currently the html-output is like this:

```
<div class="logos grid-x grid-margin-x align-middle" data-equalizer="" data-equalize-on="medium" data-resize="mkhgn8-eq" data-mutate="03dcja-eq" data-n="b1p0z1-n" data-events="resize">
    https://www.my-domain.tld/
    <a href="https://www..my-domain.tld/" target="_blank" class="logo cell medium-3 ratio1-1" data-equalizer-watch="" style="height: auto;">
        <img src="/assets/media/crops/standard.fab7edf7.logo_xyz_scaled.jpg" alt="" class="logo-img" width="182" height="53">
    </a>
https://domain.com/
    <a href="https://domain.com/" target="_blank" class="logo cell medium-3 ratio1-1" data-equalizer-watch="" style="height: auto;">
        <img src="/assets/media/crops/standard.6ef056de.logo_zz.jpg" alt="" class="logo-img" width="182" height="68">
    </a>
https://www.domain.tld/
    <a href="https://www.domain.tld/" target="_blank" class="logo cell medium-3 ratio1-1" data-equalizer-watch="" style="height: auto;">
        <img src="/assets/media/crops/standard.9eef4695.logo_test400x103.png" alt="" class="logo-img" width="182" height="52">
    </a>
</div>

```

Do I miss something? Thank’s in advance for your time!

---

<div class="post-metadata">

**Author:** ![mhamstra](https://forum.modmore.com/user_avatar/forum.modmore.com/mhamstra/32/459_2.png) [@mhamstra](https://forum.modmore.com/u/mhamstra)\
**Post date:** [May 22, 2022, 9:28am UTC](https://forum.modmore.com/t/output-modifiers-in-field-template/2352/2 "2022-05-22T09:28:28Z")

</div>

Sorry for not responding sooner. It looks like it should work to me, but maybe try this?

```auto
[[+url:notempty=`
    <a href='[[+url]]' target='_blank' class='logo cell medium-3 ratio1-1' data-equalizer-watch>
        [[+logo]]
    </a>
`:default=`
    <div class='logo cell small-6 medium-3 Xratio1-1' data-equalizer-watch>
        [[+logo]]
    </div>
`]]

```

Are you on MODX 2 or 3?

---

<div class="post-metadata">

**Author:** ![inreti](https://forum.modmore.com/letter_avatar_proxy/v4/letter/i/f0a364/32.png) [@inreti](https://forum.modmore.com/u/inreti)\
**Post date:** [May 23, 2022, 8:02am UTC](https://forum.modmore.com/t/output-modifiers-in-field-template/2352/3 "2022-05-23T08:02:04Z")

</div>

Hi Mark,

thanks for taking time. Your code works! 😀  
Why does mine does not work? I’m still on MODX 2.

Greetings, Sebastian

---

<div class="post-metadata">

**Author:** ![mhamstra](https://forum.modmore.com/user_avatar/forum.modmore.com/mhamstra/32/459_2.png) [@mhamstra](https://forum.modmore.com/u/mhamstra)\
**Post date:** [June 13, 2022, 4:00pm UTC](https://forum.modmore.com/t/output-modifiers-in-field-template/2352/4 "2022-06-13T16:00:39Z")

</div>

I think it doesn’t work with your setup because of this:

> [@inreti](#):
>
> ```auto
> [[+url:empty=`
> <div class='logo cell small-6 medium-3 Xratio1-1' data-equalizer-watch>
> [[+logo]]
> </div>
> `]]
> 
> ```

If the url is empty, it will render the logo without link

But if the url is **not** empty, it will still render the value of the url because the url placeholder value is not changed by another output modifier.

In my example, it is chained. If the url is not empty, it will render the link with logo. But the `default` clause makes sure that if the url is empty, it will render the logo in the div. So there’s both the “if” and “else” there, while your code misses additional behavior for the “else”.

---

<div class="post-metadata">

**Author:** ![inreti](https://forum.modmore.com/letter_avatar_proxy/v4/letter/i/f0a364/32.png) [@inreti](https://forum.modmore.com/u/inreti)\
**Post date:** [June 15, 2022, 1:38pm UTC](https://forum.modmore.com/t/output-modifiers-in-field-template/2352/5 "2022-06-15T13:38:12Z")

</div>

Ah… this makes sense. Thanks for your explanation, Mark!
