Seite 1 von 1

MOD für die Anzeige des letzten Beiträgs auf eigener page???

Verfasst: 02.08.2005 21:35
von Ayko
Hab schon wie ein irrer gesucht. Finde aber nichts passendes.
Ich will den letzten Beitrag immer auf meiner Homepage verkürzt (300 Zeichen oder so) anzeigen lassen. Dann kann man auf mehr klicken und kommt zum Forum.

Welchen Mod kann ich da nehmen?

Verfasst: 02.08.2005 21:39
von Scotty
Kannst du mit dem MOD hier machen, mit dem Mitarbeiter MOD, da gibt’s noch eine extra PHP Datei im Paket:
http://www.phpbb.de/moddb/staff

Hab so was bei mir auch auf der HP Eingebaut:
http://www.e-hahn.de/projekte/projekte.php

nun ja, nicht ganz so

Verfasst: 03.08.2005 17:35
von Ayko
schau mal auf: http://www.baer.de/sfb/
auf der rechten Seite siehst du wie es sein sollte. Aber die bbcodes stören halt noch.

Verfasst: 04.08.2005 08:17
von mastershowtime
@e-hahn:

Ich hab auf deiner HP geguckt, aber ich brauche den den Quelltext für die php-datei nicht den Quelltext aus der von der php-erstellten html-datei ^^

Oder anders ausgedrückt => WIE BAUE ICH DAS EIN?!?

das ist mein derzeitger code

Verfasst: 04.08.2005 22:00
von Ayko

Code: Alles auswählen

<?php
     $sql_lastpost = "SELECT * FROM `phpbb2_posts_text` ORDER BY post_id DESC LIMIT 0,1";
     $lastpost_query = mysql_query($sql_lastpost,$conn);
     $row = mysql_fetch_array($lastpost_query);
     $post_text = $row['post_text'];
     $post_subject = $row['post_subject'];
     $post_id = $row['post_id'];
     $length = strlen($post_text);
     if($length < 150)
	{
	$post_text = substr($post_text,0);
	}
      else	{
	$post_text = substr($post_text,0,strpos($post_text,' ',150));
	}
     echo("<span style=\"font-weight:bold\">$post_subject</span><br>");
     echo("$post_text");

     echo("&nbsp;<a href=\"http://forum.baer.de/viewtopic.php?p=$post_id\" target=\"_blank\">»mehr</a>");
     ?>

Verfasst: 05.08.2005 13:22
von Enano
Hast du außer dem Code noch etwas anderes PHPBB-spezifisches in deiner PHP-Seite?

Bei mir kommt nämlich nur das:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /is/htdocs/65288/www.m1v.de/index.php on line 48

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /is/htdocs/65288/www.m1v.de/index.php on line 49

Daran liegts nicht, poste mal deinen quelltext

Verfasst: 05.08.2005 20:58
von Ayko
Dein fehler liegt in zeile 48/49.
Solang ist mein script gar nicht. ;-)

Re: Daran liegts nicht, poste mal deinen quelltext

Verfasst: 05.08.2005 21:22
von Enano
Ayko hat geschrieben:Dein fehler liegt in zeile 48/49.
ehrlich? ;)

du wirst in der PHP noch irgendwo noch

Code: Alles auswählen

mysql_connect("HOST", "DBUSERNAME", "DBPASSWORT");
mysql_select_db("DBNAME");
drin haben, sonst läuft es nicht ;)

Allerdings werden dann auch die versteckten Beiträge gezeigt.
Da ich sonst nix passendes gefunden haben, habe ich mir mal etwas "zusammenkopiert" ... ich denke mal, da ist viel Überflüssiges drin. Aber wie´s mit meinem PHP steht ... siehe SIG.
Teil aus´n Recent-Mod, usw.:

Code: Alles auswählen

<table class="tableline1" width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td class="table_w" colspan="3" bgcolor="#640000"><b>die letzten Beitr&auml;ge im Forum:</b></td>
</tr>

<?php
mysql_connect("HOST", "DBUSERNAME", "DBPASSWORT");
mysql_select_db("DBNAME");
$table_prefix = 'phpbb_';
$topic_length = '30';	// length of topic title
$topic_limit = '2';	// limit of displayed topics
$special_forums = '1';	// specify forums ('0' = no; '1' = yes)
$forum_ids = '1';		// IDs of forums; separate them with a comma
$root_path = 'http://www.doemitz-forum.m1v.de/';		// link path
$content = '130';

$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.*
	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 t.topic_last_post_id = pt.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 = $root_path .'viewtopic.php?p='. $line[$i]['topic_last_post_id'] .'#'. $line[$i]['topic_last_post_id'];
	
	$post_text = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $post_text);
	$post_text = $line[$i]['post_text'];
	$post_text = ( strlen($post_text) < $content ) ? $post_text : substr(stripslashes($post_text), 0, $content) .' ... ';
	$post_text = preg_replace('#(<)([\/]?.*?)(>)#is', '', $post_text);
	$pattern = array ('/\[quote:=\'/', '/\'\]/', '/\[quote:\]/', '/\[\/quote:\]/', '/\[code:(.*?)\]/', '/\[\/code:\]/', '/\[(.*?)\]/si');
	$replace = array ('', '<b>', '</b>:: ', '<b>Zitat: </b>', '<b>Code: </b>', '');
	$post_text = preg_replace($pattern, $replace, $post_text);

	echo '<tr><td class="table_w1" width="100%" bgcolor="#410000"><b>' . $topic_type . $topic_title . '</b></td><td class="table_w1" bgcolor="#410000" nowrap>' . $last_time . '</td><td class="table_w1" bgcolor="#410000" nowrap>' . $last_author .'</td></tr><tr><td class="table_w1" colspan="3">' . $post_text . '<a href="' . $last_url . '">mehr</a><br></td></tr>';
}
mysql_close();
?>
</table>
... funktioniert, aber ;)
http://www.m1v.de (oben rechts)