die ersten 5 Beiträge aus einem Forum auf der INDEX Seite
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.
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.
-
sandra-muc
- Mitglied
- Beiträge: 17
- Registriert: 13.03.2006 16:26
die ersten 5 Beiträge aus einem Forum auf der INDEX Seite
In diesem Forum gibt es den Bereich Neuigkeiten. Dieser steht an erster Stelle. In meinem Forum soll es genau so sein. Nun möchte ich aber auf meiner INDEX Seite, die nichts mit dem Forum zu tun hat, Auszüge eben aus diesem Forenbereich haben (Neuigkeiten). Am besten die ersten 5 Beiträge. Kann mir da jemand weiterhelfen?
Ich hoffe ich habe mein Anliegen einigermaßen gut rübergebracht!
Sandra
Ich hoffe ich habe mein Anliegen einigermaßen gut rübergebracht!
Sandra
-
sandra-muc
- Mitglied
- Beiträge: 17
- Registriert: 13.03.2006 16:26
- S2B
- Ehemaliges Teammitglied
- Beiträge: 3258
- Registriert: 10.08.2004 22:48
- Wohnort: Aachen
- Kontaktdaten:
Da muss man was am Query ändern:
Finden:
in der Zeile finden:
danach einfügen:
in der Zeile (s.o.) finden:
danach einfügen:
in der Zeile (s.o.) finden:
danach einfügen:
Ausgeben kannst du den Text dann folgendermaßen (in deiner Schleife):
Der Code ist ungetestet, sollte aber normal laufen... Allerdings wirst du dann ohne BBCode-Parser auskommen müssen, denn sonst wird es um einiges komplizierter.
Für das Löschen der BBCode-UID's gibt es einen Code in der viewtopic.php:
Dann sieht der Beitrag wenigstens ein bisschen besser aus. *g*
Wenn du noch irgendwelche Fragen haben solltest, frag einfach.
Finden:
Code: Alles auswählen
$sql = "SELECT t.*, f.forum_id, f.forum_name, u.username AS first_poster, u.user_id AS first_poster_id, u2.username AS last_poster, u2.user_id AS last_poster_id, p.post_username AS first_poster_name, p2.post_username AS last_poster_name, p2.post_time
FROM ". $table_prefix ."topics t, ". $table_prefix ."forums f, ". $table_prefix ."users u, ". $table_prefix ."posts p, ". $table_prefix ."posts p2, ". $table_prefix ."users u2
WHERE $where_forums t.topic_poster = u.user_id AND f.forum_id = t.forum_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id
ORDER BY t.topic_last_post_id DESC LIMIT $topic_limit";Code: Alles auswählen
, p2.post_timeCode: Alles auswählen
, pt.post_textCode: Alles auswählen
, ". $table_prefix ."users u2Code: Alles auswählen
, " . $table_prefix . "posts_text ptCode: Alles auswählen
AND u2.user_id = p2.poster_idCode: Alles auswählen
AND pt.post_id = p.post_idCode: Alles auswählen
$line[$i]['post_text']Code: Alles auswählen
preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message)Wenn du noch irgendwelche Fragen haben solltest, frag einfach.
Gruß, S2B
Keinen Support per ICQ/PM!
Hier kann man meine PHP-Skripte und meine MODs für phpBB runterladen.
Keinen Support per ICQ/PM!
Hier kann man meine PHP-Skripte und meine MODs für phpBB runterladen.
-
sandra-muc
- Mitglied
- Beiträge: 17
- Registriert: 13.03.2006 16:26
Frisch aus dem Urlaub zurück, frag ich einfach...
Ich habe jetzt den Code eingefügt.
Aber bei der Ausgabe ändert sich (leider) nichts.
Auch möchte ich nicht das sich die Reihenfolge ändert. Also es soll immer vom ersten Posting ausgegangen werden.
Nachricht 4
Nachricht 3
Nachricht 2
Nachricht 1
Wenn eine Neue Nachricht geschreiben wurde. Dann
Nachricht 5
Nachricht 4
Nachricht 3
Nachricht 2
Nachricht 1
Auch wenn zu Nachricht 2 ein Beitrag geschrieben wurde, soll in der Zusammenfassung die Reihenfolge beibehalten werden.
Es wäre toll wenn du da noch eine Antwort für mich hättest!
Sandra
Ich habe jetzt den Code eingefügt.
Code: Alles auswählen
<?php
// ############ Edit below ########################################
$topic_length = '30'; // length of topic title
$topic_limit = '5'; // limit of displayed topics
$special_forums = '1'; // specify forums ('0' = no; '1' = yes)
$forum_ids = '2'; // IDs of forums; separate them with a comma
$config_path = '/'; // path to config.php
$root_path = '/'; // link path
// ############ Edit above ########################################
$path = dirname(__FILE__);
include_once($path.$config_path .'config.php');
mysql_connect($dbhost, $dbuser, $dbpasswd) OR die('Unable to select server.');
mysql_select_db($dbname) OR die('Unable to select database.');
// ############## output ##############
echo '<table width="100%" cellpadding="1" cellspacing="1" border="0" align="center">
<tr>
<th colspan="2">'. $topic_limit .' last topics</th>
</tr>';
// ############## output ##############
$where_forums = ( $special_forums == '0' ) ? '' : 't.forum_id IN ('. $forum_ids .') AND ';
$sql = "SELECT t.*, f.forum_id, f.forum_name, u.username AS first_poster, u.user_id AS first_poster_id, u2.username AS last_poster, u2.user_id AS last_poster_id, p.post_username AS first_poster_name, p2.post_username AS last_poster_name, p2.post_time, pt.post_text
FROM ". $table_prefix ."topics t, ". $table_prefix ."forums f, ". $table_prefix ."users u, ". $table_prefix ."posts p, ". $table_prefix ."posts p2, ". $table_prefix ."users u2, " . $table_prefix . "posts_text pt
WHERE $where_forums t.topic_poster = u.user_id AND f.forum_id = t.forum_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id AND pt.post_id = p.post_id
ORDER BY t.topic_last_post_id DESC LIMIT $topic_limit";
$result = mysql_query($sql);
if( !$result )
{
die('SQL Statement Error: '. mysql_error());
exit();
}
$line = array();
while( $row = mysql_fetch_array($result) )
{
$line[] = $row;
}
for( $i = 0; $i < count($line); $i++ )
{
$forum_id = $line[$i]['forum_id'];
$forum_url = $root_path .'viewforum.php?f='. $forum_id;
$topic_id = $line[$i]['topic_id'];
$topic_url = $root_path .'viewtopic.php?t='. $topic_id;
$topic_title = ( strlen($line[$i]['topic_title']) < $topic_length ) ? $line[$i]['topic_title'] : substr(stripslashes($line[$i]['topic_title']), 0, $topic_length) .'...';
$topic_type = ( $line[$i]['topic_type'] == '2' ) ? 'Announcement ': '';
$topic_type .= ( $line[$i]['topic_type'] == '3' ) ? 'Global Announcement ': '';
$topic_type .= ( $line[$i]['topic_type'] == '1' ) ? 'Sticky ': '';
$topic_type .= ( $line[$i]['topic_vote'] ) ? 'Poll ': '';
$views = $line[$i]['topic_views'];
$replies = $line[$i]['topic_replies'];
$first_time = date('d.m.Y', $line[$i]['topic_time']);
$first_author = ( $line[$i]['first_poster_id'] != '-1' ) ? '<a href="'. $root_path .'profile.php?mode=viewprofile&u='. $line[$i]['first_poster_id'] .'">'. $line[$i]['first_poster'] .'</a>' : ( ($line[$i]['first_poster_name'] != '' ) ? $line[$i]['first_poster_name'] : 'guest' );
$last_time = date('d.m.Y', $line[$i]['post_time']);
$last_author = ( $line[$i]['last_poster_id'] != '-1' ) ? $line[$i]['last_poster'] : ( ($line[$i]['last_poster_name'] != '' ) ? $line[$i]['last_poster_name'] : 'guest' );
$last_url = '<a href="'. $root_path .'viewtopic.php?p='. $line[$i]['topic_last_post_id'] .'#'. $line[$i]['topic_last_post_id'] .'">'. $last_author .'</a>';
// ############## output ##############
echo '<tr>
<td valign="top" nowrap="nowrap">'. $topic_type .'<a href="'. $topic_url .'">'. $topic_title .'</a></td>
</tr>
<tr>
<td><a href="'. $forum_url .'">'. $line[$i]['forum_name'] .'</a>: '. $last_url .' '. $last_time .'<br>-----------------------------------</td>
</tr>';
// ############## output ##############
}
echo '</table>';
mysql_close();
?>
Auch möchte ich nicht das sich die Reihenfolge ändert. Also es soll immer vom ersten Posting ausgegangen werden.
Nachricht 4
Nachricht 3
Nachricht 2
Nachricht 1
Wenn eine Neue Nachricht geschreiben wurde. Dann
Nachricht 5
Nachricht 4
Nachricht 3
Nachricht 2
Nachricht 1
Auch wenn zu Nachricht 2 ein Beitrag geschrieben wurde, soll in der Zusammenfassung die Reihenfolge beibehalten werden.
Es wäre toll wenn du da noch eine Antwort für mich hättest!
Sandra
- S2B
- Ehemaliges Teammitglied
- Beiträge: 3258
- Registriert: 10.08.2004 22:48
- Wohnort: Aachen
- Kontaktdaten:
Soo, zuerst mal hab ich das Query auf deine Situation angepasst und ein bisschen "ausgemistet":
Dann nochmal ausmisten:
Finden:
Ersetzen mit:
Dann musst du nur noch die entsprechenden Variablen in deinem echo ausgeben. 
Code: Alles auswählen
$sql = "SELECT t.*, f.forum_name, p.post_username AS poster_name, p.post_time, pt.post_text, u.username AS poster, u.user_id AS poster_id
FROM {$table_prefix}topics t, {$table_prefix}forums f, {$table_prefix}users u, {$table_prefix}posts p, {$table_prefix}posts_text pt
WHERE $where_forums
AND f.forum_id = t.forum_id
AND p.post_id = t.topic_first_post_id
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
ORDER BY t.topic_time DESC
LIMIT $topic_limit";Finden:
Code: Alles auswählen
$first_time = date('d.m.Y', $line[$i]['topic_time']);
$first_author = ( $line[$i]['first_poster_id'] != '-1' ) ? '<a href="'. $root_path .'profile.php?mode=viewprofile&u='. $line[$i]['first_poster_id'] .'">'. $line[$i]['first_poster'] .'</a>' : ( ($line[$i]['first_poster_name'] != '' ) ? $line[$i]['first_poster_name'] : 'guest' );
$last_time = date('d.m.Y', $line[$i]['post_time']);
$last_author = ( $line[$i]['last_poster_id'] != '-1' ) ? $line[$i]['last_poster'] : ( ($line[$i]['last_poster_name'] != '' ) ? $line[$i]['last_poster_name'] : 'guest' );
$last_url = '<a href="'. $root_path .'viewtopic.php?p='. $line[$i]['topic_last_post_id'] .'#'. $line[$i]['topic_last_post_id'] .'">'. $last_author .'</a>'; Code: Alles auswählen
$topic_time = date('d.m.Y', $line[$i]['topic_time']);
$topic_author = ($line[$i]['poster_id'] != -1) ? '<a href="'. $root_path .'profile.php?mode=viewprofile&u='. $line[$i]['poster_id'] .'">'. $line[$i]['poster'] .'</a>' : (($line[$i]['poster_name'] != '') ? $line[$i]['poster_name'] : 'Gast');Gruß, S2B
Keinen Support per ICQ/PM!
Hier kann man meine PHP-Skripte und meine MODs für phpBB runterladen.
Keinen Support per ICQ/PM!
Hier kann man meine PHP-Skripte und meine MODs für phpBB runterladen.
-
sandra-muc
- Mitglied
- Beiträge: 17
- Registriert: 13.03.2006 16:26
Wenn ich es richtig verstanden habe, dann soll ich
gegen
ersetzen!
Allerdings bekomme ich dann eine Fehlermeldung:
SQL Statement Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND f.forum_id = t.forum_id AND p.post_id = t.topic_fir
Code: Alles auswählen
$sql = "SELECT t.*, f.forum_name, p.post_username AS poster_name, p.post_time, pt.post_text, u.username AS poster, u.user_id AS poster_id
FROM {$table_prefix}topics t, {$table_prefix}forums f, {$table_prefix}users u, {$table_prefix}posts p, {$table_prefix}posts_text pt
WHERE $where_forums
AND f.forum_id = t.forum_id
AND p.post_id = t.topic_first_post_id
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
ORDER BY t.topic_time DESC
LIMIT $topic_limit";Code: Alles auswählen
$sql = "SELECT t.*, f.forum_id, f.forum_name, u.username AS first_poster, u.user_id AS first_poster_id, u2.username AS last_poster, u2.user_id AS last_poster_id, p.post_username AS first_poster_name, p2.post_username AS last_poster_name, p2.post_time, pt.post_text
FROM ". $table_prefix ."topics t, ". $table_prefix ."forums f, ". $table_prefix ."users u, ". $table_prefix ."posts p, ". $table_prefix ."posts p2, ". $table_prefix ."users u2, " . $table_prefix . "posts_text pt
WHERE $where_forums t.topic_poster = u.user_id AND f.forum_id = t.forum_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id AND pt.post_id = p.post_id
ORDER BY t.topic_last_post_id DESC LIMIT $topic_limit";
Allerdings bekomme ich dann eine Fehlermeldung:
SQL Statement Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND f.forum_id = t.forum_id AND p.post_id = t.topic_fir
- S2B
- Ehemaliges Teammitglied
- Beiträge: 3258
- Registriert: 10.08.2004 22:48
- Wohnort: Aachen
- Kontaktdaten:
Ähm, nein, den unteren Code (der stand ja schon in deiner Datei) durch den oberen.
Aber im oberen Code scheint ein Fehler zu sein.
Aber im oberen Code scheint ein Fehler zu sein.
Code: Alles auswählen
$sql = "SELECT t.*, f.forum_name, p.post_username AS poster_name, p.post_time, pt.post_text, u.username AS poster, u.user_id AS poster_id
FROM {$table_prefix}topics t, {$table_prefix}forums f, {$table_prefix}users u, {$table_prefix}posts p, {$table_prefix}posts_text pt
WHERE $where_forums
f.forum_id = t.forum_id
AND p.post_id = t.topic_first_post_id
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
ORDER BY t.topic_time DESC
LIMIT $topic_limit";Gruß, S2B
Keinen Support per ICQ/PM!
Hier kann man meine PHP-Skripte und meine MODs für phpBB runterladen.
Keinen Support per ICQ/PM!
Hier kann man meine PHP-Skripte und meine MODs für phpBB runterladen.
-
sandra-muc
- Mitglied
- Beiträge: 17
- Registriert: 13.03.2006 16:26
- S2B
- Ehemaliges Teammitglied
- Beiträge: 3258
- Registriert: 10.08.2004 22:48
- Wohnort: Aachen
- Kontaktdaten:
Die Nachricht steht in der Variable

Code: Alles auswählen
$line[$i]['post_text']Gruß, S2B
Keinen Support per ICQ/PM!
Hier kann man meine PHP-Skripte und meine MODs für phpBB runterladen.
Keinen Support per ICQ/PM!
Hier kann man meine PHP-Skripte und meine MODs für phpBB runterladen.