[RSS] di un forum Clicca QUI per vedere il messaggio nel forum |
publi |
Ho un forum in phpbb come posso creare un RSS dei nuovi argomenti che vengono creati dagli utenti? |
yeah |
Direttamente da PhpBB o come aggiunta? |
mrcnet |
PHP:
<?php
///////////////////////////////////////////////////////////////////////////////
// ACTIVE_TOPICS.PHP
///////////////////////////////////////////////////////////////////////////////
// Copyright: (C) 2002 Matthijs van de Water <matthijs@beryllium.net>
// Version: 1.1
// Date: 03/02/2002
///////////////////////////////////////////////////////////////////////////////
// Show phpBB 2.0 Active Topics List
// Output format can be any HTML or XML
// This script must be able to access vital phpBB 2.0 configuration scripts
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// CUSTOM SETTINGS
///////////////////////////////////////////////////////////////////////////////
// Amount of active topics to show
define("TOPIC_COUNT", $last);
// Path to the phpBB 2.0 root directory
define("PHPBB_PATH", "../forum/");
// URL to the phpBB 2.0 installation
define("PHPBB_LOCATION", "http://www.mrcnetwork.it/cms/forum/");
// Time format to output the date/time (for format see PHP manual)
define("TIME_FORMAT", "U");
// Title of the phpBB 2.0 installation (used for XML RDF)
// If you don't use this, you forget about this
define("PHPBB_TITLE", "mRcNEtwORK.it");
// Description of the phpBB 2.0 installation (used for XML RDF)
// If you don't use this, you forget about this
define("PHPBB_DESCRIPTION", "Ultimi messaggi Forum");
///////////////////////////////////////////////////////////////////////////////
// Includes of phpBB scripts
$phpbb_root_path = PHPBB_PATH;
if ( !defined('IN_PHPBB') )
{
define('IN_PHPBB', true);
include(PHPBB_PATH . 'extension.inc');
include(PHPBB_PATH . 'config.'.$phpEx);
include(PHPBB_PATH . 'includes/constants.'.$phpEx);
include(PHPBB_PATH . 'includes/db.'.$phpEx);
}
///////////////////////////////////////////////////////////////////////////////
// HTML header start
///////////////////////////////////////////////////////////////////////////////
// make sure this displays as XML
header("Content-type: application/xml");
header("Pragma: no-cache");
echo "<?xml version="1.0" encoding="ISO-8859-1"?>\n\n";
echo "<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"\n";
echo " "http://my.netscape.com/publish/formats/rss-0.91.dtd">\n\n";
echo "<rss version="0.91">\n\n";
echo "<channel>\n";
echo "<title>mRcNEtwORK.it</title>\n<link><a href="http://www.mrcnetwork.it/cms/index.php" target="_blank">http://www.mrcnetwork.it/cms/index.php</a></link>\n<description>Portale in espansione</description>\n";
echo "<language>it</language>\n\n";
?>
<item>
<title><?php echo PHPBB_TITLE; ?></title>
<link><a href="http://www.mrcnetwork.it" target="_blank">http://www.mrcnetwork.it</a></link>
<description><?php echo PHPBB_DESCRIPTION; ?></description>
</item>
<?php
///////////////////////////////////////////////////////////////////////////////
// HTML header end
///////////////////////////////////////////////////////////////////////////////
// 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
ORDER BY p.post_time DESC LIMIT " . TOPIC_COUNT;
$nt_result = $db->sql_query($sql);
if(!$nt_result)
{
die("Failed obtaining list of active topics".mysql_error());
}
else
{
$nt_data = $db->sql_fetchrowset($af_result);
}
if ( count($nt_data) == 0 )
{
die("No topics found");
}
else
{
// $nt_data contains all interesting data
for ($i = 0; $i < count($nt_data); $i++)
{
$title = $nt_data[$i]['topic_title'];
$url = PHPBB_LOCATION . 'viewtopic.' . $phpEx . "?" . POST_POST_URL . "=" . $nt_data[$i]['topic_last_post_id'] . "#" . $nt_data[$i]['topic_last_post_id'];
// As of now you can actually do anything with the data
// I chose to output in XML
///////////////////////////////////////////////////////////////////////////////
// Item HTML start
///////////////////////////////////////////////////////////////////////////////
?>
<item>
<title><?php echo $title; ?></title>
<link><?php echo $url; ?></link>
</item>
<?php
///////////////////////////////////////////////////////////////////////////////
// Item HTML end
///////////////////////////////////////////////////////////////////////////////
}
}
///////////////////////////////////////////////////////////////////////////////
// Footer HTML start
///////////////////////////////////////////////////////////////////////////////
?>
</channel>
</rss>
<?php
///////////////////////////////////////////////////////////////////////////////
// Footer HTML end
///////////////////////////////////////////////////////////////////////////////
// EOF
?>
in pratica non ho fato altro che modificare lo script dei thread attivi, poi ho aggiunto una variabile last in modo che è l'utente stesso a decidere quanti post visualizzare, per capirci:
http://www.mrcnetwork.it/cms/forum/feedrss.php?last=15
comodissimo da aggiungere in firefox con segnalibro live per tenere tutto sotto controllo.. |
publi |
mi sto incasinando con i link e i nomi perchè io lo uso all'interno di phpNuke O_o |
mrcnet |
ma non lo dovevi usare con phpbb? con il nuke puoi farlo sfruttando il backend.php |
publi |
come faccio col backend.php? |
mrcnet |
in che senso scusa? il backend sforna già <rss version="0.91"> |
publi |
il backend mi mostra gli rss degli articoli non i messaggi del forum... |
mrcnet |
appunto ti dicevo che non c'entra nulla.. per quelli del forum ti basta il codice che ho postato prima |
publi |
io invece ho modificato un po' il backend.php e adesso funziona come RSS del forum.
Grazie per le dritte, mi sono state utilissime! |
mrcnet |
di nulla ;)
ps. adesso dallo in pasto a google come sitemap e sei a posto |
|
|
|