We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29076
    • 615 Posts
    Is there a way to test if a document is stored only once (first time) or has been stored before and therefor is updated? I want to show an updated-on [*updatedon*] date only if the document has been stored before.

    Thanks.



      I think, thererfor I am! But what I am, and why...?
      • 36592
      • 970 Posts
      I’m not sure but "editedon" can be used for that purpose.

      The editedon field is "0" when that document is created but never edited before.
      So you can see if the document is updated.
        • 29076
        • 615 Posts
        Thanks. I’ll try that.

        That didn’t work. As far as I can tell the editedon date is set to the same value as the createddon the first time a document is stored, and not 0.
          I think, thererfor I am! But what I am, and why...?
          • 36592
          • 970 Posts
          Sorry for bad info.

          It seems that creating documents with manager interface and FDM snippet set editedon value ( which is equal to createdon value, I think.)
          But only NewsPublisher snippet leave editiedon field blank( "0" ) with document creation.
            • 4041
            • 788 Posts
            If that is the case, you could just compare the createdon and editedon fields to see if editedon is greater (which it should be if it’s been modified even if it started as zero), maybe something like this:

            <?php
            /* compare.snippet
            
            */
            $c_on =$modx->documentObject['createdon'];
            $e_on =$modx->documentObject['editedon'];
            $output ='';
            
            if( $e_on > $c_on ){
              $output .='Whatever should print if editedon is greater than createdon';
            }
            
            return $output;
            ?>
              xforum
              http://frsbuilders.net (under construction) forum for evolution
              • 29076
              • 615 Posts
              laugh Great. That works. So simple an easy. I really have to get into the MODx api my self.

              Thank you both for helping.
                I think, thererfor I am! But what I am, and why...?