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

    I have a chunk called articlePreview:
    <div class="news">
    <div class="date">
    <p><span>14</span>
    AUG</p>
    </div>
    <div class="article">
    <p><a href="[~[+id+]~]">[+pagetitle+]</a>
    [+introtext+]</p>
    </div>
    </div>

    I want the date to be generated dynamically.
    I have the Ditto call in a TV:
    [!Ditto? &startID=`7` &tpl=`articlePreview` &display=`3`!]

    I tried adding [+date+] to the chunk, replacing the <p> tag content but what do i add to the Ditto call for this to display???:
    <div class="news">
    <div class="date">
    [+date+]
    </div>
    <div class="article">
    <p><a href="[~[+id+]~]">[+pagetitle+]</a>
    [+introtext+]</p>
    </div>
    </div>

    I know this can be done because i actually got it working on another site but just can’t remember how!!!
    Thanks for any help.
    Also, where is the dynamic date generated from and can it be manipulated in any way?

    Cheers

    J
      www.9thwave.co.uk
         WEB | DESIGN | PRINT
      • 33337
      • 3,975 Posts
      &dateSource and &dateFormat
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 33337
        • 3,975 Posts
        Please see the link for more information: http://ditto.modxcms.com/files/snippet-ditto-php.html#dateSource
          Zaigham R - MODX Professional | Skype | Email | Twitter

          Digging the interwebs for #MODX gems and bringing it to you. modx.link
          • 36549
          • 572 Posts
          Hi Zi,

          Thanks for your help.

          I thought that was it but for some reason the date won’t display.
          My Ditto call from the TV is:

          [!Ditto? &startID=`7` &tpl=`articlePreview` &display=`3`&dateFormat=`<p><span>%d</span>
          %b</p>`!]

          When i look at the source code however there is a space where i’ve added [+date+] so the html source looks like this:
          <div class="date">

          </div>

          Can you see where i’m going wrong?
          Should i be adding a date manually somewhere?

          Thanks for your help

          J
            www.9thwave.co.uk
               WEB | DESIGN | PRINT
            • 36549
            • 572 Posts
            Further to my above post....I’m not sure what is going on...

            I can get the date to display using:
            [!Ditto? &startID=`7` &tpl=`articlePreview` &display=`3` &dateSource=`<p><span>%d</span>
            %b</p>`!]

            ...but it’s not displaying as ’01 JAN’
            Instead it’s displaying as 01-Jan-70 01:00

            Any ideas????

            Thanks

            J

              www.9thwave.co.uk
                 WEB | DESIGN | PRINT
              • 36549
              • 572 Posts
              Well i’ve managed to find a workaround but i’m sure it should be easier than what i’ve done...
              For anyone that needs a workaround here’s what i did...
              my source html:
              <div class="date">
              <p><span>14</span>
              AUG</p>
              </div>
              added placeholders:
              <div class="date">
              <p><span>[+description+]</span>
              [+date+]</p>
              </div>
              Ditto call:
              [!Ditto? &startID=`7` &tpl=`articlePreview` &display=`3` &dateFormat=`%b`!]

              S basically i use the description field to enter the number and use the [+date+] placeholder to generate the month...couldn’t get it to work any other way.
              It would be great if someone know a way to generate a fomatted date just by using the [+date+] placeholder and dateFormat????

              Cheers
                www.9thwave.co.uk
                   WEB | DESIGN | PRINT
                • 33337
                • 3,975 Posts
                &dateSource IS for "source" like createdon, editedon etc.

                &dateFormat IS where you need put that little html code.

                eg. &dateSource=`createdon` &dateFormat=`<p><span>%d</span>
                %b</p>`
                  Zaigham R - MODX Professional | Skype | Email | Twitter

                  Digging the interwebs for #MODX gems and bringing it to you. modx.link
                  • 36549
                  • 572 Posts
                  Hi Zi,

                  Thank you for posting a reply.
                  Unfortunately that still doesn’t work...i’ve used your suggested method like this:
                  [!Ditto? &startID=`7` &tpl=`articlePreview` &display=`3` &dateSource=`createdon` &dateFormat=`<p><span>%d</span>
                  %b</p>`!]
                  ...with [+date+] placed in the chunk but the output is no text at all displaying.

                  My previous method seems to be the only one i can get to work!!
                    www.9thwave.co.uk
                       WEB | DESIGN | PRINT