We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24799
    • 5 Posts
    добрый день.
    как вытащить ссылку на аватар веб пользователя?
      • 16702 ☆ A M B ☆
      • 536 Posts
      <?php
      $defaultavatar ='<img src="assets/images/avatars/defaultuser.gif" alt="Анонимен" border="0" />';
      $output ='';
      $tbl = $modx->dbConfig['table_prefix'];
      $authorID = isset($authid) ? $authid : $modx->documentObject['createdby'];
      $addutype ='';
      if($authorID !='' && $authorID < 0){
          $addutype ='web_';
      }
      
      if($authorID == 0){
          $output .=$defaultavatar;
      }else{
          if($authorID != ''){
              $authorID = str_replace('-','', $authorID);
              $sql = "SELECT fullname,photo
                      FROM ".$tbl.$addutype."user_attributes
                      WHERE internalKey='".$authorID."'";
      
              $rs = $this->dbQuery($sql);
              $limit = $this->recordCount($rs);
                  if($limit > 0 && $limit < 2) {
                     $user = $this->fetchRow($rs);
                     if($user['photo'] != ''){
                       $modx->setPlaceholder('author_photo', '<img width="100" height="100" class="avatar" src="'.$user['photo'].'" alt="'.$user['fullname'].'" border="0" />'); // [+author_photo+]
                     }else{
                       $modx->setPlaceholder('author_photo', '<a href="#">'.$defaultavatar.'</a>');
                     }
                  $output .='[+author_photo+]';
                  }
      
          }else{
             $output .=$defaultavatar;
          }
      }
      
      return $output;
      ?>
        palma non sine pulvere
        • 24799
        • 5 Posts
        спасибо! спас жизнь smiley