Beiträge vom Forum auf Hauptseite mit Anzahl von Antworten

Probleme bei der regulären Arbeiten mit phpBB, Fragen zu Vorgehensweisen oder Funktionsweise sowie sonstige Fragen zu phpBB im Allgemeinen.
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.1, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Antworten
Bob

Beiträge vom Forum auf Hauptseite mit Anzahl von Antworten

Beitrag von Bob »

Hallo,

wie hier Beschrieben, lasse ich jetzt meine Beiträge auf meiner Hauptseite anzeigen. Ich würde jetzt gerne noch die Anzahl der Beiträge in Klammern hinter die Themen haben. Geht das?
Bob

Beitrag von Bob »

Hat denn keiner eine Idee? :cry:
Benutzeravatar
esperitox
Mitglied
Beiträge: 803
Registriert: 17.04.2002 21:40
Wohnort: Line 758
Kontaktdaten:

Beitrag von esperitox »

rdf.php

[suchen]

Code: Alles auswählen

// SQL statement to fetch active topics of public forums
$sql = "SELECT DISTINCT t.topic_title, t.topic_last_post_id, p.post_time, f.forum_name
    FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . FORUMS_TABLE . " AS f
    WHERE
        t.forum_id = f.forum_id
            AND f.auth_view = " . AUTH_ALL . "
            AND p.topic_id = t.topic_id
            AND p.post_id = t.topic_last_post_id
            $sql_where
    ORDER BY p.post_time DESC LIMIT $count";
$topics_query = $db->sql_query($sql);

if ( !$topics_query )
{
    die("Failed obtaining list of active topics");
}
else
{
    $topics = $db->sql_fetchrowset($topics_query);
}

if ( count($topics) == 0 )
{
    die("No topics found");
}
else
{
    // $topics contains all interesting data
    for ($i = 0; $i < count($topics); $i++)
    {
        $title = $topics[$i]['topic_title'];
        $url = $viewtopic_url . "?" . POST_POST_URL . "=" . $topics[$i]['topic_last_post_id'] . "#" . $topics[$i]['topic_last_post_id'];

        $rdf .= "
<item>
    <title>" . $title . "</title>
    <link>" . $url . "</link>
</item>
";
    }
}
[Ersetzen durch]

Code: Alles auswählen

// SQL statement to fetch active topics of public forums
$sql = "SELECT DISTINCT t.topic_title, t.topic_last_post_id, t.topic_replies, p.post_time, f.forum_name
    FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . FORUMS_TABLE . " AS f
    WHERE
        t.forum_id = f.forum_id
            AND f.auth_view = " . AUTH_ALL . "
            AND p.topic_id = t.topic_id
            AND p.post_id = t.topic_last_post_id
            $sql_where
    ORDER BY p.post_time DESC LIMIT $count";
$topics_query = $db->sql_query($sql);

if ( !$topics_query )
{
    die("Failed obtaining list of active topics");
}
else
{
    $topics = $db->sql_fetchrowset($topics_query);
}

if ( count($topics) == 0 )
{
    die("No topics found");
}
else
{
    // $topics contains all interesting data
    for ($i = 0; $i < count($topics); $i++)
    {
        $title = $topics[$i]['topic_title'];
        $replies = $topics[$i]['topic_replies'];
        $url = $viewtopic_url . "?" . POST_POST_URL . "=" . $topics[$i]['topic_last_post_id'] . "#" . $topics[$i]['topic_last_post_id'];

        $rdf .= "
<item>
    <title>" . $title . "</title> (" . $replies . ")
    <link>" . $url . "</link>
</item>
";
    }
}
esperitox
Bob

Beitrag von Bob »

Danke, funktioniert. ;)

Und wie kann ich jetzt noch die Themen am ende durch "..." ersetzen lassen, falls ein Thema mal zu lang sein sollte?
Benutzeravatar
esperitox
Mitglied
Beiträge: 803
Registriert: 17.04.2002 21:40
Wohnort: Line 758
Kontaktdaten:

Beitrag von esperitox »

rdf.php

[Suchen]

Code: Alles auswählen

$title = $topics[$i]['topic_title'];
[Ersetzen durch]
$topic_title_size = 20;
$title = strlen($topics[$i]['topic_title']) > $topic_title_size ? substr($topics[$i]['topic_title'], 0, ($topic_title_size)) . "..." : $topics[$i]['topic_title'];
Bei dem Rot markierten kannst du einstellen wie lang der topic title sein darf bevor ... angezeigt wird :)

esperitox
Bob

Beitrag von Bob »

Danke, alles bestens. ;)
Antworten

Zurück zu „phpBB 2.0: Administration, Benutzung und Betrieb“