We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36632
    • 202 Posts
    Update: bug report filed:
    http://bugs.modx.com/issues/6505

    Previously my TPL contained this for styling purposes:

    [[+publishedon:strtotime:date=`<span class="post-month">%b</span> <span class="post-day">%d</span><span class="post-year">%Y</span>`]]


    But since then it's replaced the markup with html entities.

    I did install TinyMCE but doubt it affects this TPL because TPLs are not Rich Text.

    This "error" is on a site that I upgraded from 2.2RC1 to 2.2RC3 [ed. note: ultrasef last edited this post 12 years, 4 months ago.]
    • publishedon is stored as a UNIX timestamp, so I don't think that phx is correct for displaying it. This might work

      [[+publishedon:date=`<span class="post-month">%b</span> <span class="post-day">%d</span><span class="post-year">%Y</span>`]]
        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
        • 36632
        • 202 Posts
        That change yielded the same results.
          • 36632
          • 202 Posts
          [[+publishedon:strtotime:date=`%b %d %Y`]]


          the above yield the proper format, but obviously doesn't have my spans.

          I removed TinyMCE, cleared the cache, manually deleted the cache in hopes that the plugin TinyMCE was the culprit. Nope: same result. :-(

          Back to restyling this cool looking calendar div date to a very boring looking box.

          I'll file a bug for RC3.
          • I've always done it this was. Does this work?

            <span class="post-month">[[+publishedon:strtotime:date=`%b`]]</span> <span class="post-day">[[+publishedon:strtotime:date=`%d`]]</span><span class="post-year">[[+publishedon:strtotime:date=`%Y`]]</span>
              • 3749
              • 24,544 Posts
              The format string is passed to the PHP date() function, so it needs to be a valid format string.

              You could try escaping all the extra characters with a backslash:

              [[+publishedon:strtotime:date=`\<\s\p\a\n\ \c\l\a\s\s\=\"\p\o\s\t\-\m\o\n\t\h\"\>%b\<\/\s\p\a\n\>  ... etc,`]]


              Or you could do it in three parts (put these all on one line):

              <span class = "post-month>[[+publishedon:strtotime:date=`%b`]]</span>
              <span class = "post-day>[[+publishedon:strtotime:date=`%d`]]</span>
              <span class = "post-year>[[+publishedon:strtotime:date=`%Y`]]</span>
              


              Or you could use a custom snippet that calls getdate() and returns the output you want (untested):

              [[!MyDateFormat? &date=`[[+publishedon]]` ]]



              <?php
              /* MyDateFormat snippet */
              
              $dateString = $modx->getOption('date', $scriptProperties, null);
              
              $dateArray  = date_parse($dateString);
              
              $output = '<span class = "post-month>' . $dateArray['month'] . '</span>';
              $output .= '<span class = "post-day>' . $dateArray['day'] . '</span>';
              $output .= '<span class = "post-year>' . $dateArray['year'] . '</span>';
              
              return $output;
              

                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 36632
                • 202 Posts
                Thanks Bob. #2 worked after I fixed the CSS declaration ( just so you know I'm paying attention):

                <span class="post-month">[[+publishedon:strtotime:date=`%b`]]</span><span class="post-day">[[+publishedon:strtotime:date=`%d`]]</span><span class="post-year">[[+publishedon:strtotime:date=`%Y`]]</span>


                #1, with all the escaping, yielded the same old output.

                #3 I'll keep handy in case it proves to be the more elegant way to go.

                So..... this RC3 release... is this how the PHP date() function is going to be implemented? Not to sound dense, just that the original format in this post has worked for me up until RC3.
                  • 3749
                  • 24,544 Posts
                  So..... this RC3 release... is this how the PHP date() function is going to be implemented? Not to sound dense, just that the original format in this post has worked for me up until RC3.

                  This change was made in the date output modifier on Nov. 11th -- could be it:

                  Was:

                  $output= strftime($m_val,$value);


                  Now:

                  $output= htmlentities(strftime($m_val,$value),ENT_COMPAT,$encoding);
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 36632
                    • 202 Posts
                    Thanks also rx2.

                    Here's my output, all CSS with both of your help:
                    • This sounds like a bug to me; the issue that was solved by that change needs a slightly different solution IMO. I'm looking into it. FWIW, here is the original issue which triggered this change.