Seite 1 von 1
Buddielist 1.1.1.: Darstellung in Tabelle
Verfasst: 23.01.2007 13:07
von Christoph
Hallo zusammen,
ich habe eine Frage zu der Buddylist 1.1.1. und zwar habe ich folgenden Quellcode:
Code: Alles auswählen
$s_buddies = '';
if( count($buddies) == 0 )
{
$s_buddies = $lang['No_buddies'];
}
else
{
for( $i = 0; $i < count($buddies); $i++ )
{
$buddy_id = $buddies[$i]['buddy_id'];
if( ($buddies[$i]['user_allow_viewonline'] || $data['user_level'] == ADMIN) && ($buddies[$i]['user_session_time'] >= $end_session) )
{
$buddy_name = '<b>' . $buddies[$i]['buddy_name'] . '</b>';
}
else
{
$buddy_name = $buddies[$i]['buddy_name'];
}
if ($buddies[$i]['user_photo_type'] == '1'){
$buddy_userbild = 'images/photos/' . $buddies[$i]['user_photo'];
}
else
{
$buddy_userbild = 'images/photos/nopic_profil.gif';
}
$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$buddy_id");
$buddy_profile = '<td><a href="' . $temp_url . '">' . $buddy_userbild . '<br><span class="genmed">' . $buddy_name . '</span></a></td>';
$temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=$buddy_id");
$buddy_pm = '<a href="' . $temp_url . '">' . $buddy_name . '</a>';
$s_buddies .= ( ( $s_buddies != '' ) ? '</tr>' : '' ) . ( ( $mode == 'pm' ) ? $buddy_pm : $buddy_profile );
}
}
Wie passe ich diesen nun so an, dass er mir immer vier Buddies in einer Zeile anzeigt und dann ein </tr> einbaut.
Also wie folgt:
Code: Alles auswählen
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>Buddy 1</td>
<td>Buddy 2</td>
<td>Buddy 3</td>
<td>Buddy 4</td>
</tr>
<tr>
<td>Buddy 5</td>
<td>Buddy 6</td>
<td>Buddy 7</td>
<td>Buddy 8</td>
</tr>
</table>
Es sollen natürlich alle Buddies des Users so dargestellt werden, nicht nur acht Stück.
Ich hoffe ihr könnt mir helfen und habt einen Lösungsvorschlag für mich.
Danke,
Christoph
Verfasst: 23.01.2007 15:48
von Christoph
Hat niemand eine Idee wie ich das bewerkstelligen kann?
Brauche nur einen Tipp oder einen kleinen Ansatz, wie das laufen könnte.
Verfasst: 23.01.2007 16:05
von scheibenbrot
Hallo,
du solltest dir mal den
kleinen Knigge durchlesen.
Knigge hat geschrieben:Warte bitte mindestens 24h eh Du selbst auf Deine Beiträge antwortest, um sie wieder an die erste Stelle im der Themenansicht zu bringen (falls Du wenige Minuten später noch weitere Informationen hinzufügen möchtest, solltest Du stattdessen Deinen Beitrag bearbeiten). Der Mindestabstand zwischen zwei Bumps ist ebenfalls 24h.
Ebenfalls nicht erlaubt ist das Löschen eines Beitrags und darauffolgendes erneutes Posten mit dem selben Inhalt.
Du musst 24h warten bevor du auf eigene Beiträge antwortest und du hast noch nicht mal 2 gewartet
mfg
Verfasst: 23.01.2007 16:52
von Christoph
Hallo,
danke für den Hinweis... Das wusste ich nicht!
Wollten den Thread auch nicht nach oben pushen, sondern nur darstellen, dass ich verzweifelt bin.
Ich bin mir nämlich sicher, dass das ganze relativ einfach zu machen sein sollte, da ich es auf vielen anderen Webseiten mit phpBB ebenfalls gesehen habe.
Gruß
Christoph
Verfasst: 23.01.2007 16:55
von scheibenbrot
Erkläre mal genau was du machen willst...ich werde daraus nicht schlau und bestimmte andere auch nicht

Verfasst: 23.01.2007 17:04
von Christoph
Code: Alles auswählen
function get_buddies_list(&$data, $mode = '')
{
global $db, $lang, $template, $theme, $images, $userdata, $phpEx;
$current_time = time();
$session_time = 60;
$end_session = $current_time - $session_time;
$sql = "SELECT b.buddy_id, b.user_id AS buddy_userid, u.username AS buddy_name, u.user_allow_viewonline, u.user_photo, u.user_photo_type, u.user_session_time
FROM " . BUDDIES_TABLE . " b, " . USERS_TABLE . " u
WHERE b.user_id = " . $data['user_id'] . "
AND u.user_id = b.buddy_id
ORDER BY u.username ASC";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not query buddies information', '', __LINE__, __FILE__, $sql);
}
$buddies = array();
while( $row = $db->sql_fetchrow($result) )
{
$buddies[] = $row;
}
$db->sql_freeresult($result);
//
// Dump vars to template
//
$template->assign_vars(array(
'L_BUDDYLIST' => $lang['Buddylist']
)
);
//
// Okay, let's build the online buddies list
//
$s_buddies = '';
if( count($buddies) == 0 )
{
$s_buddies = $lang['No_buddies'];
}
else
{
for( $i = 0; $i < count($buddies); $i++ )
{
$buddy_id = $buddies[$i]['buddy_id'];
if( ($buddies[$i]['user_allow_viewonline'] || $data['user_level'] == ADMIN) && ($buddies[$i]['user_session_time'] >= $end_session) )
{
$buddy_name = '<b>' . $buddies[$i]['buddy_name'] . '</b>';
}
else
{
$buddy_name = $buddies[$i]['buddy_name'];
}
if ($buddies[$i]['user_photo_type'] == '1'){
$buddy_userbild = 'images/photos/' . $buddies[$i]['user_photo'];
}
else
{
$buddy_userbild = 'images/photos/nopic_profil.gif';
}
if ($buddies[$i]['buddy_userid'] == $userdata['user_id']) {
$buddy_temp_url1 = $action . ( ( preg_match('#\?#', $action) ) ? '&' : '?' ) . "buddy=remove&b=$buddy_id";
$buddy_remove_img = '<a href="' . $buddy_temp_url1 . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Remove_buddy'] . '" title="' . $lang['Remove_buddy'] . '" border="0" /></a>';
}
else
{
$buddy_remove_img = '';
}
$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$buddy_id");
$buddy_profile = '<a href="' . $temp_url . '">'. $buddy_userbild . '<br><span class="genmed">' . $buddy_name . '</span></a><br>' . $buddy_remove_img;
$temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=$buddy_id");
$buddy_pm = '<a href="' . $temp_url . '">' . $buddy_name . '</a>';
$s_buddies .= ( ( $s_buddies != '' ) ? ', ' : '' ) . ( ( $mode == 'pm' ) ? $buddy_pm : $buddy_profile );
}
}
$template->assign_vars(array(
'S_BUDDIES' => $s_buddies
)
);
return;
}
Also, die Funktion oben ist ein Auszug aus der Datei functions_buddylist.php, die dafür verantwortlich ist, dass ich den Platzhalter "S_BUDDIES" in der profile_view_body.tpl verwenden kann. Das funktioniert auch einwandfrei und alles wird dargestellt, was ich zu den Buddys abfrage.
Nun ist es aber so, dass folgende Zeile:
Code: Alles auswählen
$s_buddies .= ( ( $s_buddies != '' ) ? ', ' : '' ) . ( ( $mode == 'pm' ) ? $buddy_pm : $buddy_profile );
Die Ausgabe so macht, dass nach jedem Buddy mit Bild, Username und Deletelink ein ", " kommt und hinter dem letzten Buddy einfach nichts. Das ganze sieht dann aus wie:
http://www.hiphop-pott.de/forum/profile ... rofile&u=2, in der Box "Homies".
Nun will ich aber, dass die Buddys dargestellt werden wie folgt:
Code: Alles auswählen
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>Buddy 1</td>
<td>Buddy 2</td>
<td>Buddy 3</td>
<td>Buddy 4</td>
</tr>
<tr>
<td>Buddy 5</td>
<td>Buddy 6</td>
<td>Buddy 7</td>
<td>Buddy 8</td>
</tr>
</table>
Hoffe es ist jetzt verständlich und es gibt einen Lösungsvorschlag!
Gruß
Verfasst: 23.01.2007 18:13
von scheibenbrot
Mach doch das , weg und änder einfach alles so wie du es haben möchtest!?
Das ist ja wirklich keine Arbeit
Verfasst: 23.01.2007 18:22
von Christoph
Hallo,
habe vor lauter Bäumen den Welt wohl nicht gesehen... War absolut einfach und kein Problem, bin nur leider nicht schnell genug drauf gekommen.
Habe das nun wie folgt geändert und es läuft einwandfrei wie ich es will. Siehe:
Code: Alles auswählen
function get_buddies_list(&$data, $mode = '')
{
global $db, $lang, $template, $theme, $images, $userdata, $phpEx;
$current_time = time();
$session_time = 60;
$end_session = $current_time - $session_time;
$sql = "SELECT b.buddy_id, b.user_id AS buddy_userid, u.username AS buddy_name, u.user_allow_viewonline, u.user_photo, u.user_photo_type, u.user_session_time
FROM " . BUDDIES_TABLE . " b, " . USERS_TABLE . " u
WHERE b.user_id = " . $data['user_id'] . "
AND u.user_id = b.buddy_id
ORDER BY u.username ASC";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not query buddies information', '', __LINE__, __FILE__, $sql);
}
$buddies = array();
while( $row = $db->sql_fetchrow($result) )
{
$buddies[] = $row;
}
$db->sql_freeresult($result);
//
// Dump vars to template
//
$template->assign_vars(array(
'L_BUDDYLIST' => $lang['Buddylist']
)
);
//
// Okay, let's build the online buddies list
//
$s_buddies = '';
if( count($buddies) == 0 )
{
$s_buddies = $lang['No_buddies'];
}
else
{
$buddy_count = 0;
for( $i = 0; $i < count($buddies); $i++ )
{
$buddy_id = $buddies[$i]['buddy_id'];
if( ($buddies[$i]['user_allow_viewonline'] || $data['user_level'] == ADMIN) && ($buddies[$i]['user_session_time'] >= $end_session) )
{
$buddy_name = '<b>' . $buddies[$i]['buddy_name'] . '</b>';
}
else
{
$buddy_name = $buddies[$i]['buddy_name'];
}
if ($buddies[$i]['user_photo_type'] == '1'){
$buddy_userbild = 'images/photos/' . $buddies[$i]['user_photo'];
}
else
{
$buddy_userbild = 'images/photos/nopic_profil.gif';
}
if ($buddies[$i]['buddy_userid'] == $userdata['user_id']) {
$buddy_temp_url1 = $action . ( ( preg_match('#\?#', $action) ) ? '&' : '?' ) . "buddy=remove&b=$buddy_id";
$buddy_remove_img = '<a href="' . $buddy_temp_url1 . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Remove_buddy'] . '" title="' . $lang['Remove_buddy'] . '" border="0" /></a>';
}
else
{
$buddy_remove_img = '';
}
$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$buddy_id");
$buddy_profile = '<td><a href="' . $temp_url . '">'. $buddy_userbild . '<br><span class="genmed">' . $buddy_name . '</span></a><br>' . $buddy_remove_img . '</td>';
$temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=$buddy_id");
$buddy_pm = '<a href="' . $temp_url . '">' . $buddy_name . '</a>';
$s_buddies .= ( ( $s_buddies != '' ) ? '' : '' ) . ( ( $mode == 'pm' ) ? $buddy_pm : $buddy_profile );
$buddy_count++;
if ($buddy_count == '3'){
$s_buddies .= '</tr><tr>';
$buddy_count = 0;
}
}
}
$template->assign_vars(array(
'S_BUDDIES' => $s_buddies
)
);
return;
}
Verfasst: 23.01.2007 20:27
von scheibenbrot
na siehste...
Verfasst: 26.01.2007 12:04
von Christoph
Hallo,
da bin ich auch schon wieder...
Nachdem gestern mein Server abgeschmiert ist, da laut den Angaben des Technikers der Speicher überlastet wurde, bin ich nun auf der Suche nach der Ursache. Da ich in den letzten Tagen aktiv nur an einer Funktion gearbeitet habe, stelle ich die Behauptung auf, dass der Fehler in dieser Funktion liegt. Allerdings finde ich diesen nicht, da meiner Meinung nach in der Funktion alles richtig ist.
Es würde mich freuen, wenn ihr über die folgende Funktion auch noch einmal drüber schauen könntet und falls ihr Fehler findet die die Ursache für die Serverauslastung sein könnten, mir diese mitteilt. Vielen Dank.
Code: Alles auswählen
function get_buddies_list(&$data, $mode = '')
{
global $db, $lang, $template, $theme, $images, $u, $userdata, $phpEx;
$current_time = time();
$session_time = 60;
$end_session = $current_time - $session_time;
$sql = "SELECT b.buddy_id, b.user_id AS buddy_userid, u.username AS buddy_name, u.user_allow_viewonline, u.user_photo, u.user_photo_type, u.user_session_time
FROM " . BUDDIES_TABLE . " b, " . USERS_TABLE . " u
WHERE b.user_id = " . $data['user_id'] . "
AND u.user_id = b.buddy_id
ORDER BY u.username ASC";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not query buddies information', '', __LINE__, __FILE__, $sql);
}
$buddyanzahl = mysql_num_rows($result);
$buddies = array();
while( $row = $db->sql_fetchrow($result) )
{
$buddies[] = $row;
}
$db->sql_freeresult($result);
//
// Dump vars to template
//
$template->assign_vars(array(
'L_BUDDYLIST' => $lang['Buddylist']
)
);
//
// Okay, let's build the online buddies list
//
$s_buddies = '';
if( count($buddies) == 0 )
{
$s_buddies .= '<table width="100%" border="0" cellspacing="0" cellpadding="5"><tr><td align="center"><b>Noch keine Homies vorhanden!</b></td>';
}
else
{
$buddy_count = 0;
$buddy_count1 = 0;
$s_buddies .= '<table width="100%" border="0" cellspacing="0" cellpadding="5"><tr>';
for( $i = 0; $i < count($buddies); $i++ )
{
$buddy_id = $buddies[$i]['buddy_id'];
if( ($buddies[$i]['user_allow_viewonline'] || $data['user_level'] == ADMIN) && ($buddies[$i]['user_session_time'] >= $end_session) )
{
$buddy_name = '<font color="#009900"><b>' . $buddies[$i]['buddy_name'] . '</b></font>';
$buddy_name_online = '<img src="templates/subSilver/images/online.gif" alt="Online" title="Online" border="0">';
}
else
{
$buddy_name = $buddies[$i]['buddy_name'];
$buddy_name_online = '';
}
if ($buddies[$i]['user_photo_type'] == '1'){
$buddy_userbild = 'images/photos/' . $buddies[$i]['user_photo'];
}
else
{
$buddy_userbild = 'images/photos/nopic_profil.gif';
}
$buddy_temp_url1 = $action . ( ( preg_match('#\?#', $action) ) ? '&' : '?' ) . "mode=viewprofile&u=$u&buddy=remove&b=$buddy_id";
if ($buddies[$i]['buddy_userid'] == $userdata['user_id']) {
$buddy_remove_img = ' <a href="' . $buddy_temp_url1 . '"><img src="templates/subSilver/images/profil/buddy_loeschen.gif" width="11" height="11" alt="' . $lang['Remove_buddy'] . '" title="' . $lang['Remove_buddy'] . '" border="0"></a>';
}
else
{
$buddy_remove_img = '';
}
$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$buddy_id");
$buddy_profile = '<td width="142" align="center" valign="top"><a href="' . $temp_url . '"><img src="'. $buddy_userbild . '" width="80" height="80" border="1" class="Border" alt="Zum Profil" title="Zum Profil"><br>' . $buddy_name . '</a>' . $buddy_remove_img . '<br>' . $buddy_name_online . '</td>';
$temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=$buddy_id");
$buddy_pm = '<a href="' . $temp_url . '">' . $buddy_name . '</a>';
$s_buddies .= ( ( $s_buddies != '' ) ? '' : '' ) . ( ( $mode == 'pm' ) ? $buddy_pm : $buddy_profile );
$buddy_count++;
$buddy_count1++;
if ($buddy_count == '3'){
if ($buddy_count1 == '6') {
$s_buddies .= '</tr></table><table width="100%" border="0" cellspacing="0" cellpadding="5" id="homies" style="display:none; visibility:hidden"><tr>';
}
else
{
$s_buddies .= '</tr><tr>';
}
$buddy_count = 0;
}
}
}
if ($i > '10'){
$s_buddies .= '</tr></table><table width="100%" border="0" cellspacing="0" cellpadding="5"><tr><td align="right"><span style="background-color:#FFFFFF"> <img src="templates/subSilver/images/profil/plus.gif" alt="Ein- / Ausklappen" width="11" height="11" border="0" title="Ein- / Ausklappen" id="hmimg"> <a href="javascript:hmvisible(\'homies\')"><b><span id="hm">Weitere Homies</span></b></a> </span></td></tr></table>';
}
else
{
$s_buddies .= '</tr></table>';
}
$template->assign_vars(array(
'S_BUDDIES' => $s_buddies,
'S_BUDDIES_AN' => $buddyanzahl
)
);
return;
}
Diese Funktion stammt aus der Datei "functions_buddylist.php", des Mods Buddylist 1.1.1 von Freakin' Booty, die ich an meine Bedürfnisse angepasst habe.
Gruß
Christoph