PHP code example of friends-of-contao / contao-memberlist

1. Go to this page and download the library: Download friends-of-contao/contao-memberlist library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

friends-of-contao / contao-memberlist example snippets


// config.php
$GLOBALS['TL_HOOKS']['memberListFormatValue'][] = array('MyClass', 'formatValue');

// MyClass.php
public function formatValue($k, $value, $objMember, $blnListSingle=false)
{
  // Avatar
  if (strcmp($GLOBALS['TL_DCA']['tl_member']['fields'][$k]['inputType'], 'avatar') == 0)
  {
    $objFile = \FilesModel::findByUuid($value);
    if ($objFile === null && $GLOBALS['TL_CONFIG']['avatar_fallback_image']) {
      $objFile = \FilesModel::findByUuid($GLOBALS['TL_CONFIG']['avatar_fallback_image']);
    }

    $strAlt = $objMember->firstname . " " . $objMember->lastname;
    if ($objFile !== null) {
      $value = '<img src="' . TL_FILES_URL . \Image::get(
        $objFile->path,
        $arrImage[0],
        $arrImage[1],
        $arrImage[2]
        ) . '" width="' . $arrImage[0] . '" height="' . $arrImage[1] . '" alt="' . $strAlt . '" class="avatar">';
    }
    else
    {
      $value = "-";
    }
    return $value;
  }
  return false;
}