1) creare un file lista_topics.php di questo tipo:
Codice: Seleziona tutto
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewtopic');
// Lista degli ultimi Topics by Micogian / Bingo
$sql = "SELECT topic_id, forum_id, topic_title, topic_time, topic_moved_id, topic_first_poster_name
FROM " . TOPICS_TABLE . "
WHERE topic_type = 0
AND topic_moved_id = 0
ORDER BY topic_time DESC LIMIT 0,30";
$result = $db->sql_query($sql);
$n = 0;
while ($row = $db->sql_fetchrow($result))
{
if ($auth->acl_get('f_read', $row['forum_id']) == 1)
{
if ($n < 20)
{
// accorcia il titolo del topic
if (strlen($row['topic_title'] > '28'))
{
$title_short[$n] = substr($row['topic_title'],0,27) . "...";
}else{
$title_short[$n] = $row['topic_title'];
}
$topic_id[$n] = $row['topic_id'];
$topic_link[$n] = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=" . $row['forum_id'] . "&t=" . $row['topic_id']);
$topic_title[$n] = $row['topic_title'];
$topic_author[$n] = $row['topic_first_poster_name'];
++$n ;
}
}
}
// FINE query Ultimi Topics
Nel file HTML (che chiamerai index.php) fai così:
Codice: Seleziona tutto
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title>oltrecomics.com • Indice</title>
<link href=oltredemo.css rel="stylesheet" type="text/css">
<?php
include ("lista_topic.php");
?>
</head>
<body>
<!-- qui il resto della pagina -->
</body>
</html>
Codice: Seleziona tutto
<?php
// Lista degli ultimi topics
for ($y = '0';$y < $n;++$y)
{
echo "<img src='images/ico_05.png'> <a href=http://tuo_dominio/forum/viewtopic.php?t=" . $topic_id[$y] . " title='" . $topic_title[$y] . "'>" . $title_short[$y] . "...</a> (" . $topic_author[$y] . ")<br>" ;
}
?>