We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38462
    • 39 Posts
    Shawn,
    I've had a look at what you have referenced, this is exactly what I am looking to do - insert an extra div class if publishedon is greater than today's date -30 days, using the following code:

    strtotime snippet:
    <?php
    /* stringToTime snippet */
    return strtotime($input);


    [[+publishedon:gt=`[[!strtotime? &input=`-30 days`]]`:then=`event old`:else=`event new`]]


    When getResources is cached it defaults to first conditional value. When uncached it works for the first resource, then all other revert to first conditional value.

    Even when I use directly within a template resource (not a getResources call) using the following:

    getNow snippet:
    <?php
    // last month
    return mktime(0, 0, 0, date("m")-1, date("d"), date("Y"));
    


    [[*publishedon:strtotime:lt=`[[!getNow]]`:then=`event old`:else=`event new`]]


    I still get the first conditional value?

    Stumped?




      • 38462
      • 39 Posts
      Got it working now direct on resource template when I omit
      :else=`event new`
        • 38462
        • 39 Posts
        Got this working now using calcAge snippet https://gist.github.com/bertoost/6225003
        I amended the last line of the snippet:
        return floor((time() - $date) / (60 * 60 * 24));


        tplchunk:
        [[+createdon:calcAge:gte=`31`:then=`Old Content`:else=`New Content`]]