Date condition not working

I’m trying to display a badge depending on a selected date range. I have created two date TVs, badgeStart and badgeEnd, and installed the snippet getDate.

If I just output their values in my chunk all looks fine. This code:

Now date: [[!getDate:date=`%Y%m%d`]]<br>
Start date: [[+tv.badgeStart:date=`%Y%m%d`]]<br>
End date: [[+tv.badgeEnd:date=`%Y%m%d`]]<br>

Returns this:

Now date: 20230707
Start date: 20230706
End date: 20231231

However, this code won’t display the text “Show Badge” for some reason.

    [[+tv.badgeStart:date=`%Y%m%d`:lt=`[[!getDate:date=`%Y%m%d`]]`:then=`
        [[+tv.badgeEnd:date=`%Y%m%d`:gt=`[[!getDate:date=`%Y%m%d`]]`:then=`
            Show Badge
        `:else=``]]
    `:else=``]]

I’m using MODX 3.0.4-dev and PHP 8.2.7.

The solution was as simple as changing the pdoResources call I am using from cached – [[pdoResources]] – to uncached – [[!pdoResources]] :roll_eyes:

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.