We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7155
    • 160 Posts
    Hi,

    I am using the latest Evolution Release and have phX installed.

    My challenge is that I have a TV that is a date variable(Unixtime) used in a Ditto call.

    It formats nicely using &dateFormat parameter without any problems

    I now want to further work on the [+date+] placeholder that is created by Ditto.

    Instead of outputting it as it is, I would like to split it so that I have a Month separated from Day. I use the format string `%b %d`. So intended to split it using the space as a delimiter(straightforward in PHP)

    Here are some of the things I tried that have failed me:

    - I tried creating a snippet that calls and returns the [+date+] placeholder using $modx->getPlaceholder(’date’) and also tried $modx->placeholders[’date’]

    - I tried and failed to understand how to create a custom extender, which I assume is what I need so I can split the [+date+] placeholder as I require using PHP. I have gone through the specific example in the example.extender.inc.php file but I have failed to make sense of it.

    Here are some search results I went through but havent really helped me understand:

    http://modxcms.com/forums/index.php/topic,27564.msg168495.html
    http://modxcms.com/forums/index.php?topic=16013.0
    http://modxcms.com/forums/index.php?topic=35848.0
    http://modxcms.com/forums/index.php?topic=26641.0

    From the WIKI
    http://wiki.modxcms.com/index.php/Ditto_Custom_Placeholders

    Perhaps I am slow (shrug), but I did try.

    Hope someone can help.

    Thanks for the great tool!!!



      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You could try using the [+date+] placeholder twice:

      No, of course not! The date placeholder is already converted from the raw timestamp, so applying date formatters to it won’t work!

      Try using the raw [+createdon:date=%b+] and [+createdon:date=%d+] instead.

      And you don’t need to install the phx plugin for this; Ditto has its own phx internally.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 7155
        • 160 Posts
        Thanks Susan,

        My original intention had been to work on the already formatted value. e.g, the date format string I used was `%b %d`( the Ditto call would have the parameters: &dateFormat=`%b %d` &dateSource=`MyDateTV` ). Since Ditto outputs the result in the placeholder called [+date+], all I wanted to do was work on that output value.

        BUT, as always smiley , I think you’ve provided me with an elegant solution. I didnt know Ditto had its internal phx. Thanks again, Susan!

        P.S.
        I think I would still like to understand how the Ditto extenders work. May come in handy
          • 7155
          • 160 Posts
          That did it! Thanks, Susan. You may have forgotten to put backticks.