We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10241
    • 57 Posts
    How do I display the author on a published page?
      • 33337
      • 3,975 Posts
      You need a snippet "Author TimeStamp" or similar, please search in Extras section.
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 29076
        • 615 Posts
        This one works for me:
        <?php
        /*    Author_name_photo
        
        */
        $output ="";
        $tbl = $modx->dbConfig['table_prefix'];
        $authorID = isset($authorid) ? $authorid : $modx->documentObject['createdby'];
        
        if($authorID != ""){
        $sql = "SELECT fullname,photo,email
              FROM ".$tbl."user_attributes
              WHERE ".$tbl."user_attributes.internalKey = ".$authorID;
        
              $rs = $this->dbQuery($sql);
              $limit = $this->recordCount($rs);
              if($limit > 0 && $limit < 2) {
                 $user = $this->fetchRow($rs);
        
                 $modx->setPlaceholder('author_fullname', $user['fullname']);     // [+author_fullname+]
                 $modx->setPlaceholder('author_email', $user['email']);     // [+author_email+]
                 if($user['photo'] != ""){
                   $modx->setPlaceholder('author_photo', '<img class="publisererFoto" src="'.$user['photo'].'" alt="'.$user['fullname'].'" width="45" height="45" />');           // [+author_photo+]
                 }else{
                   $modx->setPlaceholder('author_photo', 'no photo available');
                 }
               // print out the info or use it in a chunk after the snippet is called
              $output .="[+author_photo+]";
              $output .="<div class=\"publisererNavn\">Av:<br /><a href=\"mailto:[+author_email+]\">[+author_fullname+]</a></div>";
              }
        
        }
        
        return $output;
        ?>
          I think, thererfor I am! But what I am, and why...?
          • 3749
          • 24,544 Posts
          Or, for MODx Revolution:

          $user = $modx->resource->getOne('CreatedBy');
          return $user->get('username');


          For the author’s full name:

          $user = $modx->resource->getOne('CreatedBy');
          $profile = $user->getOne('Profile');
          return $profile->get('fullname');


          In Revo, you can also do it this way:

          [[*createdby:userinfo=`username`]]


          Note the capital letters in some (but not all) of the arguments.
            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
            • 29076
            • 615 Posts
            Hey, thats great. I’ll look into that BobRay. smiley
              I think, thererfor I am! But what I am, and why...?
              • 10241
              • 57 Posts
              thanks for all the advice. they seem to work except with NewsPublisher. maybe i’ll have to try revolution on my test site and see if that works.