ViewTopic & Autordaten in einer extra 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
Kathrin01
Mitglied
Beiträge: 15
Registriert: 23.08.2004 18:43

ViewTopic & Autordaten in einer extra tabelle

Beitrag von Kathrin01 »

Huhu,

kann mir jemand sagen wie ich in der viewtopic.php die Daten vom ersteller auslesen kann? Bevor man den eigentlichen Beitrag sieht habe ich eine Tabelle erstellt in der Name, eMail, Web, MSN,Icq vom Autor stehen soll. Ich dachte ich wäre schlau und setzte einfach folgenden text über meine tabelle:
<!-- BEGIN postrow -->
Und habe dann in meine einzelnen Spalten eingefügt was angezeigt werden soll (z.b.: {postrow.POSTER_NAME} etc) dummerweise wird jetzt meine neue Tabelle über den Antworten auch immer angezeigt :( Möchte aber nur das die am anfang des Topics steht und nur die Daten vom ersteller anzeigt :oops: Habe leider nicht viel ahnung mit SQL :( Ein bekannter von mir meinte ich müsste das neu auslesen ?¿! Ist dies irgendwie möglich?
Christian_W
Ehemaliges Teammitglied
Beiträge: 5703
Registriert: 26.02.2004 00:09

Beitrag von Christian_W »

Kann sein, dass da nicht alle Variablen zusammenpassen aber ich denke man kann damit arbeiten.

Code: Alles auswählen

----- öffne -----
viewtopic.php

----- finde -----
//
// Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ...
//

----- füge davor ein -----
$thread_starter = ( $postrow[0]['user_id'] == ANONYMOUS ) ? $lang['Guest'] : $postrow[0]['username'];
$thread_start_date = create_date($board_config['default_dateformat'], $postrow[0]['post_time'], $board_config['board_timezone']);
$thread_starter_posts = ( $postrow[0]['user_id'] != ANONYMOUS ) ? $lang['Posts'] . ': ' . $postrow[0]['user_posts'] : '';
$thread_starter_from = ( $postrow[0]['user_from'] && $postrow[0]['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $postrow[0]['user_from'] : '';

if ( $postrow[0]['user_id'] != ANONYMOUS )
{
	$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $postrow[0]['user_id']);
	$thread_starter_profile_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_profile'] . '" alt="' . $lang['Read_profile'] . '" title="' . $lang['Read_profile'] . '" border="0" /></a>';
	$thread_starter_profile = '<a href="' . $temp_url . '">' . $lang['Read_profile'] . '</a>';

	$temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=" . $postrow[0]['user_id']);
	$thread_starter_pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
	$thread_starter_pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>';

	if ( !empty($postrow[0]['user_viewemail']) || $is_auth['auth_mod'] )
	{
		$email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $postrow[0]['user_id']) : 'mailto:' . $postrow[0]['user_email'];

		$thread_starter_email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>';
		$thread_starter_email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
	}
	else
	{
		$thread_starter_email_img = '';
		$thread_starter_email = '';
	}

	$thread_starter_www_img = ( $postrow[0]['user_website'] ) ? '<a href="' . $postrow[0]['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '';
	$thread_starter_www = ( $postrow[0]['user_website'] ) ? '<a href="' . $postrow[0]['user_website'] . '" target="_userwww">' . $lang['Visit_website'] . '</a>' : '';

	if ( !empty($postrow[0]['user_icq']) )
	{
		$thread_starter_icq_status_img = '<a href="http://wwp.icq.com/' . $postrow[0]['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $postrow[0]['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>';
		$thread_starter_icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow[0]['user_icq'] . '"><img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ'] . '" title="' . $lang['ICQ'] . '" border="0" /></a>';
		$thread_starter_icq =  '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow[0]['user_icq'] . '">' . $lang['ICQ'] . '</a>';
	}
	else
	{
		$thread_starter_icq_status_img = '';
		$thread_starter_icq_img = '';
		$thread_starter_icq = '';
	}

	$thread_starter_aim_img = ( $postrow[0]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[0]['user_aim'] . '&message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : '';
	$thread_starter_aim = ( $postrow[0]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[0]['user_aim'] . '&message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : '';

	$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $postrow[0]['user_id']);
	$thread_starter_msn_img = ( $postrow[0]['user_msnm'] ) ? '<a href="' . $temp_url . '"><img src="' . $images['icon_msnm'] . '" alt="' . $lang['MSNM'] . '" title="' . $lang['MSNM'] . '" border="0" /></a>' : '';
	$thread_starter_msn = ( $postrow[0]['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $lang['MSNM'] . '</a>' : '';

	$thread_starter_yim_img = ( $postrow[0]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[0]['user_yim'] . '&.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : '';
	$thread_starter_yim = ( $postrow[0]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[0]['user_yim'] . '&.src=pg">' . $lang['YIM'] . '</a>' : '';
}
else
{
	$thread_starter_profile_img = '';
	$thread_starter_profile = '';
	$thread_starter_pm_img = '';
	$thread_starter_pm = '';
	$thread_starter_email_img = '';
	$thread_starter_email = '';
	$thread_starter_www_img = '';
	$thread_starter_www = '';
	$thread_starter_icq_status_img = '';
	$thread_starter_icq_img = '';
	$thread_starter_icq = '';
	$thread_starter_aim_img = '';
	$thread_starter_aim = '';
	$thread_starter_msn_img = '';
	$thread_starter_msn = '';
	$thread_starter_yim_img = '';
	$thread_starter_yim = '';
}

$thread_starter = ( $postrow[0]['user_id'] == ANONYMOUS ) ? $lang['Guest'] : $postrow[0]['username'];
$thread_start_date = create_date($board_config['default_dateformat'], $postrow[0]['post_time'], $board_config['board_timezone']);
$thread_starter_posts = ( $postrow[0]['user_id'] != ANONYMOUS ) ? $lang['Posts'] . ': ' . $postrow[0]['user_posts'] : '';
$thread_starter_from = ( $postrow[0]['user_from'] && $postrow[0]['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $postrow[0]['user_from'] : '';

$template->assign_vars(array(
	'THREAD_STARTER_NAME' => $thread_starter,
	'THREAD_START_DATE' => $thread_start_date,
	'THREAD_STARTER_POSTS' => $thread_starter_posts,
	'THREAD_STARTER_FROM' => $thread_starter_from,

	'THREAD_STARTER_PROFILE_IMG' => $thread_starter_profile_img,
	'THREAD_STARTER_PROFILE' => $thread_starter_profile,
	'THREAD_STARTER_PM_IMG' => $thread_starter_pm_img,
	'THREAD_STARTER_PM' => $thread_starter_pm,
	'THREAD_STARTER_EMAIL_IMG' => $thread_starter_email_img,
	'THREAD_STARTER_EMAIL' => $thread_starter_email,
	'THREAD_STARTER_WWW_IMG' => $thread_starter_www_img,
	'THREAD_STARTER_WWW' => $thread_starter_www,
	'THREAD_STARTER_ICQ_STATUS_IMG' => $thread_starter_icq_status_img,
	'THREAD_STARTER_ICQ_IMG' => $thread_starter_icq_img,
	'THREAD_STARTER_ICQ' => $thread_starter_icq,
	'THREAD_STARTER_AIM_IMG' => $thread_starter_aim_img,
	'THREAD_STARTER_AIM' => $thread_starter_aim,
	'THREAD_STARTER_MSN_IMG' => $thread_starter_msn_img,
	'THREAD_STARTER_MSN' => $thread_starter_msn,
	'THREAD_STARTER_YIM_IMG' => $thread_starter_yim_img,
	'THREAD_STARTER_YIM' => $thread_starter_yim,
));
In der viewtopic_body.tpl kannst Du dann diese Variablen verwenden:
THREAD_STARTER_NAME wird zu {THREAD_STARTER_NAME}
THREAD_START_DATE wird zu {THREAD_START_DATE}
usw.

Gruß Christian
---
Kathrin01
Mitglied
Beiträge: 15
Registriert: 23.08.2004 18:43

Beitrag von Kathrin01 »

erstmal vielen lieben dank für deine Arbeit :oops:
Hat fast alles supi funktioniert :D


Konnte das ganze auch fein erweitern ... habe nur ein Problem mit dem post_text :cry:

Habe folgendes nach

Code: Alles auswählen

$thread_starter_from = ( $postrow[0]['user_from'] && $postrow[0]['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $postrow[0]['user_from'] : ''; 
eingefügt:

Code: Alles auswählen

$thread_starter_post= $postrow[0]['post_text']; 
Und nach :

Code: Alles auswählen

$template->assign_vars(array( 
   'THREAD_STARTER_NAME' => $thread_starter,
dieses eingefügt:

Code: Alles auswählen

'THREAD_STARTER_POST' => $thread_starter_post,
Der Text wird auch wunderbar angezeigt ... jedoch werden formatierungen bbcode etc alles nicht angezeigt :( Kannst du mir vll. noch sagen wie ich das anstelle, dass er "richtig" angezeigt wird?
Christian_W
Ehemaliges Teammitglied
Beiträge: 5703
Registriert: 26.02.2004 00:09

Beitrag von Christian_W »

Kathrin01 hat geschrieben:Konnte das ganze auch fein erweitern ... habe nur ein Problem mit dem post_text :cry:
Der Text ist auch etwas komplexer und muss durch einige Funktionen damit er korrekt angezeigt wird.

Die oben genannten Änderungen musst Du schon gemacht haben:

Code: Alles auswählen

----- finde -----
$thread_starter_from = ( $postrow[0]['user_from'] && $postrow[0]['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $postrow[0]['user_from'] : '';

----- füge danach ein -----
$message = $postrow[0]['post_text'];
$bbcode_uid = $postrow[0]['bbcode_uid'];

if ( !$board_config['allow_html'] )
{
	if ( $postrow[0]['enable_html'] )
	{
		$message = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $message);
	}
}

if ( $board_config['allow_bbcode'] )
{
	if ( $bbcode_uid != '' )
	{
		$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
	}
}

$message = make_clickable($message);

if ( $board_config['allow_smilies'] )
{
	if ( $postrow[0]['user_allowsmile'] && $user_sig != '' )
	{
		$user_sig = smilies_pass($user_sig);
	}
	if ( $postrow[0]['enable_smilies'] )
	{
		$message = smilies_pass($message);
	}
}

if ($highlight_match)
{
	// This was shamelessly 'borrowed' from volker at multiartstudio dot de
	// via php.net's annotated manual
	$message = str_replace('"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $highlight_match . ")\b#i', '<span style="color:#" . $theme['fontcolor3'] . ""><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));
}

if (count($orig_word))
{
	$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
	$message = str_replace('"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
}
$message = str_replace("\n", "\n<br />\n", $message);

----- finde -----
	'THREAD_STARTER_YIM' => $thread_starter_yim,

----- füge danach ein
	'THREAD_STARTER_POST' => $message,
Gruß Christian
---
Antworten

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