We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25551 ☆ A M B ☆
    • 1,231 Posts
    Hey folks,

    I’m wishing to show when a document was last edited on and I’ve searched the forums and tried to make sense of all the ideas.

    Basically if I use ditto and put the placeholder in my Tpl [+editedon+] it’s showing the Unixtime 1214602234. I’ve tried understanding PHx and when I used the placeholder it had in the wiki, the time format was right but the date was set to 1970.

    If I use [+date+] the date is correct but I want to use editedon so the user knows when the document was last edited (of course lol).

    Could someone be so kind to help me?

    Ross

    EDIT: I finally got it working using [+editedon:date=`%a %B %d, %Y at %H:%M`+]
      Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
      AugmentBLU - MODX Partner

      BLUcart - MODX Revolution E-Commerce & Shopping Cart
      • 25551 ☆ A M B ☆
      • 1,231 Posts
      On a related note... I have a parent folder and 3 child docs within this parent. I would like the parent to reflect that the child docs have been updated. How can I make ditto tell the parent that it one of it’s child docs have been updated and have it show in the parent link that it was updated on date xxx.

      Thanks.
        Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
        AugmentBLU - MODX Partner

        BLUcart - MODX Revolution E-Commerce & Shopping Cart
        • 7231
        • 4,205 Posts
        How are you generating the links to the sub documents? Wayfinder or Ditto? If in ditto just add the date placeholder to the tpl. In Wayfinder, I am not sure if the editedon placeholder is available within the tpl chunks. In either case you will need to build a custom snippet to output the editedon date in the menu.

        Here is an example:
        <?php
        $field = "editedon";
        if ($docId != "") { 
        	$doc = $modx->getDocument($docId, $field);
        	return strftime( "%c" ,$doc[$field]);
        } else {
        	return "";
        }	
        ?>


        then in the wayfinder tpl you would add the snippet with the doc id as the input:
         [!getEditon?&docId=`[+wf.docid+]`!] 


        Note: you can format the output date format by editing the strftime() part of the code. Look here for the available options.
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don&#39;t know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 25551 ☆ A M B ☆
          • 1,231 Posts
          I’m using Ditto...

          My tpl is

          <div class="ditto_item" id="ditto_item_[+id+]">
          <h4 style="padding:10px" class="ditto_pageTitle"><a href="[~[+id+]~]">[+author+]’s [+pagetitle+]</a>

          Updated On : [+date+]

          </h4>

          </div>

          It’s only giving the date of when the parent was created?
            Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
            AugmentBLU - MODX Partner

            BLUcart - MODX Revolution E-Commerce & Shopping Cart
            • 7231
            • 4,205 Posts
            Did you include &dateSource=`editedon` in your ditto call? If that does not work you can use the [+editedon+] placeholder in the tlp but you will need another snippet to format the display (like the dateTime snippet) since it is a time stamp. You can also use the snippet above but change the call to :
            [!getEditon?&docId=`[+id+]`!]
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 25551 ☆ A M B ☆
              • 1,231 Posts
              Yeah it’s showing the time and date but it’s not showing the date of the latest edited child document... I have a parent doc using a ditto call and 3 child docs that use Jot and FDM. Jot doesn’t actually update the child doc editedon time but the FDM time does change it’s editedon date. It’s showing up in the child editedon call but it’s not being reflected in the parent ditto call that one of it’s child docs has been edited.

              Does this make sense? LOL
                Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                AugmentBLU - MODX Partner

                BLUcart - MODX Revolution E-Commerce & Shopping Cart
                • 7231
                • 4,205 Posts
                Could it be cache related? Does the editedon date change if you edit from the manager instead of FDM? I think that NewsPublisher has a setting to force the cache to refresh, not sure if FDM needs this as well.
                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don&#39;t know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 25551 ☆ A M B ☆
                  • 1,231 Posts
                  I just saved the child doc in the manager and it shows in the child that it was just updated.... cleared the cache in the manager and checked the parent and there’s no update.

                  :(
                    Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                    AugmentBLU - MODX Partner

                    BLUcart - MODX Revolution E-Commerce & Shopping Cart
                    • 25551 ☆ A M B ☆
                    • 1,231 Posts
                    Sorry, I just re-looked at my folder structure. IT may hold clues why it’s not working

                    OVERALL PARENT
                    +Sub Parent
                    +child 1
                    +child 2
                    +child 3
                    +Sub Parent
                    +child 1
                    +child 2
                    +child 3

                    OVERALL PARENT

                    Ditto :
                    [!Ditto? &tpl=`MainMembersPagesTpl` &dateSource=`createdon` &showInMenuOnly=`1` &summarize=`15` &total=`9` &sortBy=`createdon` &sortDir=`ASC` &descendentDepth=`3` !]

                    MainMembersPagesTpl :
                    <div class="ditto_item" id="ditto_item_[+id+]">
                    <h4 style="padding:10px" class="ditto_pageTitle"><a href="[~[+id+]~]">[+author+]’s [+pagetitle+]</a></h4>
                    <p style="margin-left:10px">Created On : [+date+] || Updated On : [[getEditon? &docId=`[+id+]`]]</p> </div>


                    Sub Parent

                    Ditto :
                    [!Ditto? &tpl=`MembersPagesTpl` &showInMenuOnly=`1` &summarize=`15` &total=`9` &sortBy=`createdon` &sortDir=`ASC` &descendentDepth=`3` !]

                    MembersPagesTpl :
                    <div class="ditto_item" id="ditto_item_[+id+]">
                    <h4 style="padding:10px" class="ditto_pageTitle"><a href="[~[+id+]~]">[+author+]’s [+pagetitle+]</a>

                    Last Update : [+editedon:date=`%a %B %d, %Y at %H:%M`+]</h4> </div>

                    Child 1, 2 , 3

                    No Ditto Calls.

                    Hope this makes sense.
                      Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                      AugmentBLU - MODX Partner

                      BLUcart - MODX Revolution E-Commerce & Shopping Cart
                      • 7231
                      • 4,205 Posts
                      Oh, I think I now understand what you are wanting. In the structure you provided you want the the sub parent to show when one of it’s children has last been edited, not when itself has been edited. So that when you edit child1, the menu for the sub Parent will know that the the child was updated.

                      I think this will require a custom snippet to check the edit date of the children and post the most recent.
                        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                        Something is happening here, but you don&#39;t know what it is.
                        Do you, Mr. Jones? - [bob dylan]