We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39273
    • 61 Posts
    I am trying to show the user full name of the person who edited a resource, but only when the resource has been edited (otherwise it displays '0').

    I am using the following with no success:

    [[*editedby:gt=`0`:then=userinfo=`fullname`:else=``]]


    What is the correct procedure to display the fullname of editedby ONLY when there has been a revision? [ed. note: leemchildress last edited this post 12 years, 7 months ago.]
      • 3749
      • 24,544 Posts
      I would do something like this. It would be significantly faster.

      <p>Revised by: [[!ShowEditedBy]]</p>

      /* ShowEditedBy snippet */
      
      $doc = $modx->resource;
      $editorId = $doc->get('editedby');
      
      $output = '';
      if (!empty($editorId)) {
          $profile = $modx->getObject('modUserProfile', array('internalKey' => $editorId));
          if ($profile) {
              $output = $profile->get('fullname');
          } 
        /* Optional - show date of edit */
          $editedOn = $doc->get('editedon');
          if (! empty($editedOn) {
              $output .= ' -- ' . $editedOn;
          }
        /* *** */
      
      }
      
      
      return $output;
      





      [ed. note: BobRay last edited this post 12 years, 7 months ago.]
        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
        • 39273
        • 61 Posts
        Thanks! Worked like a charm. For anyone else who uses this code be sure to add a semi-colan ";" at the end of Line 10.
          • 3749
          • 24,544 Posts
          I'm glad it worked for you. smiley

          I fixed the code above.
            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