ThWboard Support-Forum (Archiv)

Ort: / Boardübersicht / Code Hack Requests / Die letzten X Posts auf der Homepage


Seite 1 von 2 – nächste Seite >>

[TMB] DOOMER schrieb am 02.11.2002 um 02:46 Uhr

Servus,
also ich würde gerne die letzten 7-10 Posts als kurze Zeilen in meine Homepage einbinden, ohne mich im Forum zu befinden.
Kann da mal jemand schnell was zusammenprogrammieren, ich blick da bei der search.php nicht ganz durch.

Am besten wäre natürlich ein eigenes Design, z.B.:

Forumüberschrift2 (Doomer)
Forumüberschrift7 (Terminator)
Forumüberschrift32 (NaXos)

oder:

Forumübers... (Doomer)
Forumübers... (Terminator)
usw.

oder:
Doomer - Forumü...
Termi... - Forumü...


Naja, wie es aussieht ist mir fast egal, hauptsache es passt in die Homepage.
Gibts sowas schon oder könnte das sonst bitte mal einer machen ?

Thanks

Bluetooth schrieb am 02.11.2002 um 07:11 Uhr

Also sowas hab ich mal im Statistik-Center programmiert, ist aber nicht mehr ganz aktuell

[TMB] DOOMER schrieb am 02.11.2002 um 20:28 Uhr

Also ich hab jetzt n bissle was rausgefiltert, komm jetzt aber nicht weiter...

<?php
include ("/www/htdocs/v031736/php/cfg/webdesign.inc.php");
include ("$abpfad/php/forum/inc/header.inc.php");

function getlastposts($show = 0, $num = 10)
{
global $pref;

if( !$show )
{
$query = "SELECT post.threadid, post.posttime, thread.threadtopic, board.boardname FROM ".$pref."post As post, ".$pref."thread As thread,
".$pref."board As board WHERE thread.threadid = post.threadid AND board.boardid = thread.boardid
AND board.boarddisabled = 0 ORDER BY post.posttime DESC LIMIT $num";
}
else
{
$query = "SELECT post.threadid, post.posttime, thread.threadtopic, board.boardname FROM ".$pref."post As post, ".$pref."thread As thread,
".$pref."board As board WHERE thread.threadid = post.threadid AND board.boardid = thread.boardid ORDER BY post.posttime DESC LIMIT $num";
}
$r_posts = thwb_query($query);
$a_posts = array();
while( $datarow = mysql_fetch_array($r_posts) )
{
$a_posts[] = $datarow;
}
return $a_posts;
}



# Block Lastposts

$lposts = getlastposts($sconf['showall']);
$i = 1;
$topbgcol = "$style[CellA]";
foreach( $lposts As $thread )
{
$thread['num'] = $i;
$thread['bgcolor'] = $topbgcol;
$thread['sort'] = "<nobr>" . form_date($thread['posttime']) . "</nobr>";
eval($Tthreads->GetTemplate("astats['toplastposts']"));
$i++;
if( $topbgcol == "$style[CellA]" )
{
$topbgcol = "$style[CellB]";
}
else
{
$topbgcol = "$style[CellA]";
}
}

# Ende Block Lastposts
?>


Ergebnis ist ein:
Fatal error: Call to a member function on a non-object in /www/htdocs/v031736/php/forum/test.php on line 41

sprich die:
eval($Tthreads->GetTemplate("astats['toplastposts']"));

Leider kenn ich mich nicht so aus mit php.
Später will ich die Datei einfach per include-befehl in meine homepage holen.
Ich brauche also keine Template (ausser sie is zwingend erforderlich).
Wie kann ich das also gleich ausgeben lassen ??

Jonas schrieb am 03.11.2002 um 17:55 Uhr

schnassel hat da mal was auf thwh gemacht, such dort bitte ein bisschen ;)

Schnassel63 schrieb am 03.11.2002 um 20:14 Uhr

hehe nicht alles verraten ;)

wenn die leute mal ein bissel schauen würden, dann hätte der eine oder andere bemerkt, das so ein script bei mir schon eine weile im gange ist

aber eine sig ist ja nur zum lachen da :(

[TMB] DOOMER schrieb am 03.11.2002 um 21:24 Uhr

Also ich habs jetzt fast selber geschaft...

ich hab nur noch ein paar überflüssige Datein in denen nur eine müll zeile steht... z.B.

$Tframe = new Template("templates/" . $style['styletemplate'] . "/testframe.html");
#da steht nur das CONTENT drin
$Tstats = new Template("templates/" . $style['styletemplate'] . "/test.html");
#da steht nur das astats['toplastposts'] drin


eval($Tstats->GetTemplate("CONTENT"));
eval($Tframe->GetTemplate());

Leider scheint es nicht ohne zu funktionieren...
Wo find ich denn dein Script dazu ???

Schnassel63 schrieb am 03.11.2002 um 21:47 Uhr

schau dir mal diesen Beitrag an Post Nr017
das ist die Lösung welche bei mir läuft
http://hacks.slware.com/tboard/showtopic.php?threadid=140&time=1036013684

code copieren und als php speichern
dann entwerder includen, oder wenn es in einer html-seite eingebunden werden soll als iframe

[TMB] DOOMER schrieb am 03.11.2002 um 23:06 Uhr

Das script funktioniert nicht ganz (post 017)
Fatal error: Call to undefined function: tb_query() in /www/htdocs/v031736/php/forum/test.php on line 26

oder

$r_active_threads = tb_query("SELECT post.posttime, post.threadid, thread.threadtopic, board.boardname FROM $pref"."post AS post, $pref"."thread AS thread, $pref"."board AS board WHERE post.threadid = thread.threadid AND board.boardid = thread.boardid ".$query_str." ORDER BY posttime DESC");

hmpf... aber wir sind nah dran an der Lösung...

Schnassel63 schrieb am 03.11.2002 um 23:12 Uhr

jau, schau ich mir morgen mal an

das teil wurde ja auch für die 2.7 geschrieben (siehe Sig Win-Forum dort findest du das script life), da kann schon sein, das es in der 2.8 einiges net gibt oder anders betitelt ist ;)

Schnassel63 schrieb am 03.11.2002 um 23:38 Uhr

probiere mal diesen code

<?
include "./inc/header.inc.php";

switch ($g_user['userlevel']) {
      case 0:
            //normaler User / Gast
            $query_str = "AND board.boarddisabled = 0";
            break;
      case 1:
            //Administrator / Operator
            $query_str = "";
            break;
       default:
            //normaler User / Gast
            $query_str = "AND board.boarddisabled = 0";
            break;
}

$i=0;
$a_active_threads = array();
$r_active_threads = thwb_query("
                        SELECT post.posttime, post.threadid, thread.threadtopic, board.boardname
                        FROM $pref"."post AS post, $pref"."thread AS thread, $pref"."board AS board
                        WHERE post.threadid = thread.threadid AND board.boardid = thread.boardid ".$query_str."
                        ORDER BY posttime DESC");
while( $active_threads = mysql_fetch_array($r_active_threads) )
{

       if (in_array ($active_threads['threadid'], $a_active_threads))
       {
             continue;
       }
       else
       {
             $a_active_threads [] = $active_threads['threadid'];
             $i++;
             if ($i < 10)
             {
                $ii='&nbsp;';
                $ii .=$i;
             }
             else
             {
                $ii=$i;
             }

             $active_threads_table      .= "<nobr><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">$ii. <a target=\"_top\" href=\"".$config[board_baseurl]."/showtopic.php?threadid=".$active_threads['threadid']."\">".$active_threads['threadtopic'].'</a>'
                                                .'&nbsp;&nbsp; - &nbsp;&nbsp;'
                                                .'<font size="1">'
                                                .form_date($active_threads['posttime'])
                                                .'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;« <font color="#333366" size="1">Board: '
                                                .$active_threads['boardname']
                                                .'</font> »</nobr><br></font>';
       }
       if ($i == "10") { break; }
}
print $active_threads_table;

?>



das sollte so gehen für die 2.8, habs aber net getestet, morgen dann falls es net gehen sollte ;)

und die datei muss im forum-verzeichniss liegen

[TMB] DOOMER schrieb am 03.11.2002 um 23:52 Uhr

Sorry, geht leider auch nicht...

Fatal error: Call to undefined function: tb_query() in /www/htdocs/v031736/php/forum/test.php on line 26


aber macht nix, mein Script ist sogut wie fertig...
http://www.tmb-clan.net/php/forum/lastxposts.php

[TMB] DOOMER schrieb am 04.11.2002 um 00:06 Uhr

Lol so ein Dreck...

Das Forum ist noch nicht installiert! Klicken Sie hier, um mit der Installation zu beginnen.



wenn ichs einbinden will kommt die meldung da oben ^^^

Vorschläge ?

<?
include "$abpfad/php/forum/inc/header.inc.php";

function getlastposts($show = 0, $num = 10)
{
    global $pref;
    
    if( !$show )
    {
        $query = "SELECT post.threadid, post.posttime, thread.threadtopic, board.boardname FROM ".$pref."post As post, ".$pref."thread As thread,
                ".$pref."board As board WHERE thread.threadid = post.threadid AND board.boardid = thread.boardid
                AND board.boarddisabled = 0 ORDER BY post.posttime DESC LIMIT $num";
    }
    else
    {
        $query = "SELECT post.threadid, post.posttime, thread.threadtopic, board.boardname FROM ".$pref."post As post, ".$pref."thread As thread,
                ".$pref."board As board WHERE thread.threadid = post.threadid AND board.boardid = thread.boardid ORDER BY post.posttime DESC LIMIT $num";
    }
    $r_posts = thwb_query($query);
    $a_posts = array();
    while( $datarow = mysql_fetch_array($r_posts) )
    {
        $a_posts[] = $datarow;
    }
    return $a_posts;
}


$Tthreads = new Template("templates/" . $style['styletemplate'] . "/lastxposts.html");


# Block Lastposts

$lposts = getlastposts($sconf['showall']);
$i = 1;
$topbgcol = "$style[CellA]";
foreach( $lposts As $thread )
{
    $thread['num'] = $i;
    $thread['bgcolor'] = $topbgcol;
    $thread['sort'] = "<nobr>" . form_date($thread['posttime']) . "</nobr>";
    eval($Tthreads->GetTemplate("astats['toplastposts']"));
    $i++;
    if( $topbgcol == "$style[CellA]" )
    {
        $topbgcol = "$style[CellB]";
    }
    else
    {
        $topbgcol = "$style[CellA]";
    }
}

# Ende Block Lastposts


$Tstats = new Template("templates/" . $style['styletemplate'] . "/lastxposts2.html"); 
eval ($Tstats->GetTemplate());

[TMB] DOOMER schrieb am 07.11.2002 um 22:58 Uhr

@Schnassel63

also kann ja sein das dein code bei dir funktioniert, bei mir geht er wahrscheinlich nicht, weil die verschiedenen Datenbanknamen anders heissen. Kann das sein ?

Hat jemand ne Idee wie ich den Satz "Das Forum ist noch nicht installiert! Klicken Sie hier, um mit der Installation zu beginnen." rauskriege ?

Jetzt kommt schon, das kann doch alles nich so schwer sein !

:\

Schnassel63 schrieb am 08.11.2002 um 05:31 Uhr

ich habe leider noch nicht die Zeit gehabt, das genau zu testen
mach ich übers Wochenende

zumal ich dachte, das sich das schon erledigt hatte :(
siehe Dein Post 010

[TMB] DOOMER schrieb am 08.11.2002 um 10:48 Uhr

ok danke.

Es würde ja gehen, wenn da nicht die komische Abfrage mit dem Installiertem Forum wäre.

Superhausi schrieb am 08.11.2002 um 11:26 Uhr

Du darfst die header.inc.php nur aus dem Board-Verz. includen. Wenn du sie von irgendwo anders haben willst, musst du:
1. Mögl:
config.inc.php und functions.inc.php einzeln includen (sauberer)
2. Mögl: Dort ein Verzeichniss inc erstellen, welches
a) per Filepointer auf das andere inc zeigt (nur Unix)
b) die Files config.inc.php und functions.inc.php enthällt

[TMB] DOOMER schrieb am 08.11.2002 um 16:03 Uhr

Drecks Templates.

wie kann ich den Block:

# Block Lastposts

$lposts = getlastposts($sconf['showall']);
$i = 1;
$topbgcol = "$style[CellA]";
foreach( $lposts As $thread )
{
    $thread['num'] = $i;
    $thread['bgcolor'] = $topbgcol;
    $thread['sort'] = "<nobr>" . form_date($thread['posttime']) . "</nobr>";
    eval($Tthreads->GetTemplate("astats['toplastposts']"));
    $i++;
    if( $topbgcol == "$style[CellA]" )
    {
        $topbgcol = "$style[CellB]";
    }
    else
    {
        $topbgcol = "$style[CellA]";
    }
}

# Ende Block Lastposts


direkt in der lastxposts.php ausgeben. Also direkt da wo sie auch drin steht.

Schnassel63 schrieb am 09.11.2002 um 11:33 Uhr

so ich habe das mal getestet
vom Prinzip funzt das Script

mehr infos gibt es hier

[TMB] DOOMER schrieb am 09.11.2002 um 14:40 Uhr

Jub das Teil im link geht, hier nochmal der Code:

<?
include "[color="red"]absoluterpfad[/color]/inc/config.inc.php";
include "[color="red"]absoluterpfad[/color]/inc/functions.inc.php";


$i=0;
$a_active_threads = array();
$r_active_threads = thwb_query("
                        SELECT post.posttime, post.threadid, thread.threadtopic, board.boardname
                        FROM $pref"."group, $pref"."post AS post, $pref"."thread AS thread, $pref"."board AS board
                        WHERE post.threadid = thread.threadid AND board.boardid = thread.boardid AND board.boarddisabled = 0
                        ORDER BY posttime DESC");
while( $active_threads = mysql_fetch_array($r_active_threads) )
{

       if (in_array ($active_threads['threadid'], $a_active_threads))
       {
             continue;
       }
       else
       {
             $a_active_threads [] = $active_threads['threadid'];
             $i++;
             if ($i < 10)
             {
                $ii='&nbsp;';
                $ii .=$i;
             }
             else
             {
                $ii=$i;
             }

             $active_threads_table      .= "<nobr><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">$ii. <a target=\"_top\" href=\"".$config[board_baseurl]."/showtopic.php?threadid=".$active_threads['threadid']."\">".$active_threads['threadtopic'].'</a>'
                                                .'&nbsp;&nbsp; - &nbsp;&nbsp;'
                                                .'<font size="1">'
                                                .form_date($active_threads['posttime'])
                                                .'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;« <font color="#333366" size="1">Board: '
                                                .$active_threads['boardname']
                                                .'</font> »</nobr><br></font>';
       }
       if ($i == "10") { break; }
}
print $active_threads_table;

?>



1000x DANKE

=) =) =) =) =) =)

Schnassel63 schrieb am 09.11.2002 um 14:44 Uhr

wenn du die php aus dem forum-ordner laden würdest, dann bräuchtest du diese umständlichen includes nicht

es werden bei diesen script aber immer noch die internen foren ausgegeben, an alle user, auch welche keinen zugriff auf die internen foren haben :(

hoffe du hast das auch gelesen
erst wenn die internen foren für gäste usw nicht mit ausgegeben werden, ist das script 100% ok

[TMB] DOOMER schrieb am 09.11.2002 um 15:40 Uhr

Wie meinst Du das "die ph aus dem forum ordner laden" ?
ich bin nich so fit in php, ich möchte sie ja in den News stehen haben.
Welchen Befehl muss ich denn sonst verwenden wenn nicht include ?

interne Foren
is zwar nich so doll, aber auch nicht soooo schlimm, da wir noch ein 2. forum intern haben, was extra läuft. Und da stehen die wirklich internen sachen drin.

[TMB] DOOMER schrieb am 10.11.2002 um 17:35 Uhr

Also bei mir gibt er keine Internen Foren aus. nur halt den Beitragsnamen, aber das is mir egal, solange nicht gelesen werden kann.

Ich hab mich vorhin mal ausgeloggt und dann auf ein internes Thema geklickt. Und da wollte er das ich mich einlogge.

Also prima leistung find ich.

Danke nochmal

Schnassel63 schrieb am 10.11.2002 um 19:29 Uhr

aber manschmal, oder viel öfter verrät ein thread schon um was es geht
das ist oft net gut
besser wäre schon, wenn die internen forn nicht ausgegeben werden ;)

chris hunter schrieb am 18.12.2002 um 21:54 Uhr

ich hab sowas ähnliches auch bei mir eingebaut. jetzt hab ich aber das problem, das einige threads doppelt angezeigt werden. ich will jetzt aber immer nur jemweils die letzte antwort in einem thread angezeigt bekommen. also


thread 12 posting 50
thread 23 posting 10
thread 14 posting 13

und nicht

thread 12 posting 50
thread 12 posting 49
thread 23 posting 10

meine mysql abfrage sieht im moment so aus:

[CODE]

$r_posts = thwb_query("SELECT posttime, postguestname, threadid, userid FROM $pref"."post ORDER BY posttime DESC LIMIT $numofpostings");

[/CODE]

wie muss ich die abfrage denn jetzt ändern? ich glaube das geht irgendwie mit GROUP aber ich bekomms nicht hin...

chris hunter schrieb am 18.12.2002 um 21:56 Uhr

ach ich poste grad mal meine lösung. muss eingefügt werden in der index.php ganz am ende vor den zeilen mit eval

im template muss dann nurnoch die variabel $last10 an der stelle eingetragen werden wo die tabelle angezeigt werden soll


//die letzten 10 Postings anzeigen
$numofpostings=10;
$last10="
<U>Die letzten $numofpostings Postings</U><BR>
<TABLE border=0 width=100% cellspacing=1>
<TR>
    <TD>$style[stdfont]Thema/Forum$style[stdfontend]</TD>
    <TD colspan=2 align=center>$style[stdfont]Antworten/Hits$style[stdfontend]</TD>
    <TD width=100>$style[stdfont]Letzter Beitrag$style[stdfontend]</TD>
</TR>";
$r_posts = thwb_query("SELECT posttime, postguestname, threadid, userid FROM $pref"."post GROUP BY threadid ORDER BY posttime DESC LIMIT $numofpostings");
$cnt=0;
$color1=$style[CellA];
$color2=$style[CellB];
while($lpost=mysql_fetch_array($r_posts))
{
  $cnt++;
  $lpost[posttime]=form_date($lpost[posttime], 1);
  if ($thisrowcolor==$color2) 
  {
    $thisrowcolor=$color1;
  }
  else
  {
    $thisrowcolor=$color2;
  }
   
  if($lpost[userid]!=0)
  {
    $r_user = thwb_query("SELECT username FROM $pref"."user WHERE userid=$lpost[userid] LIMIT 1");
    $luser=mysql_fetch_array($r_user);
    $lpost[postguestname]=$luser[username];
  }
  $r_thread = thwb_query("SELECT threadtopic, threadviews, threadreplies, threadlastreplyby, boardid FROM $pref"."thread WHERE threadid=$lpost[threadid] LIMIT 1");
  $lthread=mysql_fetch_array($r_thread);
  
  $r_board = thwb_query("SELECT boardname FROM $pref"."board WHERE boardid=$lthread[boardid] LIMIT 1");
  $lboard=mysql_fetch_array($r_board);
  
  $last10 .=eval($Tlast10->GetTemplate("last10"));
}
$last10 .="</TABLE>";

Seite 1 von 2 – nächste Seite >>