Hello,
What I am trying to accomplish, is have a users buddies photo thumbnail show up, in their profile.
this works except for the ones that do not have a photo. These have a default photo in "/components/com_comprofiler/images/english/tnnophoto.jpg".
I would like the no photo image to show up.
The database is set up like this: the info for the avatar is stored in mos_comprofiler as id, user_id, avatar, avatarapproved. If the user has no avatar the field is empty.
How would I be able to query or sort the relults so that the users with with empty avatar field show the default photo with link to photo?
IF ($ueConfig['showbuddylistinprofile']==1)
{
$query = "SELECT buddyid FROM #__comprofiler_buddylist WHERE userid='".$user->id."' ";
$database->setQuery($query);
$result = '';
$result = $database->loadObjectList();
$total = count ($result);
if ($total>0)
{
$j=0;
$buddy='';
foreach($result as $preuser)
{
$buddy[$j]=$preuser->buddyid;
$j++;
}
$passtoquery='(' . implode(',', $buddy) . ')';
$query = "SELECT id,username FROM #__users WHERE id IN ".$passtoquery." AND block!=1 ORDER BY username";
$database->setQuery($query);
$buds = $database->loadObjectList();
echo "<tr><td colspan=2 align=center align=center class=\"sectiontableheader\">Buddies of ".$user->username."</td></tr>";
echo "<tr><td>";
//Begin Code in Question
foreach($buds as $bud)
{
$query_avatar = "SELECT avatar FROM mos_comprofiler WHERE user_id='".$bud->id."' AND avatarapproved=1";
$database->setQuery( $query_avatar );
$pics = $database->loadObjectList();
$path = "index.php?option=com_comprofiler&task=userProfile&user=";
$thumb_path ="images/comprofiler/tn";
$no_photo_image = "/components/com_comprofiler/images/english/tnnophoto.jpg";
foreach($pics as $pic)
if($ueConfig['allow_profilelink']==1)
{
echo "<a href=".sefRelToAbs.$path.$bud->id."><img src=".$thumb_path.$pic->avatar.">".$bud->username."</a><br/> ";
}
else
{
echo $bud->username." ";
}
}
echo "</td></tr>";
}
}
//End Code in Question
You can view a profile at
http://acatexperience.com
select the memberlist and view a profile(some members do not have any buddies yet) My profile is "thehuman".
I do not have the buddy thumbnail implemented as it does not fully work yet.
Thanks for any help or suggestions.
Jeff