Buddielist 1.1.1.: Darstellung in Tabelle

In diesem Forum können Mod-Autoren ihre Mods vorstellen, die sich noch im Entwicklungsstatus befinden. Der Einbau in Foren im produktiven Betrieb wird nicht empfohlen.
Forumsregeln
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.0, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Antworten
Benutzeravatar
Christoph
Mitglied
Beiträge: 82
Registriert: 20.05.2003 21:33
Wohnort: Bochum
Kontaktdaten:

Buddielist 1.1.1.: Darstellung in Tabelle

Beitrag 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
Benutzeravatar
Christoph
Mitglied
Beiträge: 82
Registriert: 20.05.2003 21:33
Wohnort: Bochum
Kontaktdaten:

Beitrag von Christoph »

Hat niemand eine Idee wie ich das bewerkstelligen kann?
Brauche nur einen Tipp oder einen kleinen Ansatz, wie das laufen könnte.
Benutzeravatar
scheibenbrot
Mitglied
Beiträge: 1552
Registriert: 23.12.2005 14:32

Beitrag 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
Love is the slowest form of suicide.
Benutzeravatar
Christoph
Mitglied
Beiträge: 82
Registriert: 20.05.2003 21:33
Wohnort: Bochum
Kontaktdaten:

Beitrag 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
Benutzeravatar
scheibenbrot
Mitglied
Beiträge: 1552
Registriert: 23.12.2005 14:32

Beitrag von scheibenbrot »

Erkläre mal genau was du machen willst...ich werde daraus nicht schlau und bestimmte andere auch nicht :oops: :wink:
Love is the slowest form of suicide.
Benutzeravatar
Christoph
Mitglied
Beiträge: 82
Registriert: 20.05.2003 21:33
Wohnort: Bochum
Kontaktdaten:

Beitrag 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ß
Benutzeravatar
scheibenbrot
Mitglied
Beiträge: 1552
Registriert: 23.12.2005 14:32

Beitrag von scheibenbrot »

Mach doch das , weg und änder einfach alles so wie du es haben möchtest!?
Das ist ja wirklich keine Arbeit
Love is the slowest form of suicide.
Benutzeravatar
Christoph
Mitglied
Beiträge: 82
Registriert: 20.05.2003 21:33
Wohnort: Bochum
Kontaktdaten:

Beitrag 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;
}
Benutzeravatar
scheibenbrot
Mitglied
Beiträge: 1552
Registriert: 23.12.2005 14:32

Beitrag von scheibenbrot »

na siehste...
Love is the slowest form of suicide.
Benutzeravatar
Christoph
Mitglied
Beiträge: 82
Registriert: 20.05.2003 21:33
Wohnort: Bochum
Kontaktdaten:

Beitrag 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">&nbsp;<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>&nbsp;</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
Antworten

Zurück zu „phpBB 2.0: Mods in Entwicklung“