Comme je le disais sur un autre topic de ce forum, ma conversion de phpBB2 à phpBB3 se déroule très bien pour le moment (grâce à dcz), mais un problème persiste : je n'arrive pas à afficher les 10 derniers topics sur une page externe. Ou plutôt si, il s'affichent bien mais les urls ne sont pas correctes. J'ai essayé de comprendre et après avoir lu des 10aines de posts sur le sujet ici ou ailleurs, pioché dans différents bouts de codes que j'ai pu trouver, je n'y parviens toujours pas. J'suis en mode avancé 3.0.6.
Donc tantôt j'obtiens l'url :
mondomaine/forum/titre-sujet.html : Mais sans l'id, donc page non trouvée
Tantôt
mondomaine/forum/topicXXXX.html : Là, la redirection se fait bien sur titre-sujet-tXX.html, preuve que le rewrit fonctionne bien, mais je voudrais évidemment mon titre-sujet-tXX.html
Y'a-t-il un code propre, complet, quelquepart ? Pour info, je voudrais obtenir :
Titre du sujet - Titre du forum - Dernier message par XXXX - dd/mm/yy à 19:35
Pour le moment mon code ressemble à ça, celui qui correspond au dernier exemple que j'obtiens (topicXXXX.html) :
- Code: Tout sélectionner
<?php
define('IN_SITE', true);
define('IN_PHPBB', true);
$phpbb_root_path = './forum2/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Sélection des 10 derniers posts
$sql = "SELECT topic_replies_real,topic_replies,topic_title,forum_id,topic_id,topic_type,topic_last_post_id
FROM phpbb_topics
WHERE topic_approved = 1
ORDER BY topic_last_post_time DESC
LIMIT 10";
$result = $db->sql_query($sql);
// Boucle d'affichage du post
while($topic_data = $db->sql_fetchrow($result))
{
// Données du topic
$topic_title = $topic_data['topic_title'];
$forum_id = $topic_data['forum_id'];
$topic_id = $topic_data['topic_id'];
// Url du post
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
$topic_data['topic_title'] = censor_text($topic_data['topic_title']);
if (empty($phpbb_seo->seo_opt['virtual_folder']) || !empty($phpbb_seo->seo_url['forum'][$forum_id]) || $topic_data['topic_type'] == POST_GLOBAL)
{
$phpbb_seo->prepare_iurl($topic_data, 'topic', $topic_data['topic_type'] == POST_GLOBAL ? $phpbb_seo->seo_static['global_announce'] :
$phpbb_seo->seo_url['forum'][$forum_id]);
}
// www.phpBB-SEO.com SEO TOOLKIT END
$post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id");
//On affiche
echo '<li><a href="'.$post_url.'">'.$topic_title.'</a></li>';
}
$db->sql_freeresult($result);
?>
Et celui du titre-sujet.html, sans l'id, et avec en prime un problème d'encodage utf8 :
- Code: Tout sélectionner
<?php
define('IN_SITE', true);
define('IN_PHPBB', true);
$phpbb_root_path = './forum2/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Sélection des 10 derniers posts
$sql = "SELECT t.topic_replies_real,t.topic_replies,t.topic_title,t.forum_id,t.topic_id,t.topic_type,t.topic_last_post_id,f.forum_name,t.topic_last_poster_name,t.topic_last_post_time
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
WHERE t.topic_approved = 1
AND t.topic_status <> 2
AND t.forum_id = f.forum_id
ORDER BY t.topic_last_post_time DESC
LIMIT 6";
$result = $db->sql_query($sql);
// Boucle d'affichage du post
while($topic_data = $db->sql_fetchrow($result))
{
// Données du topic
$topic_title = $topic_data['topic_title'];
$topic_replies = $topic_data['topic_replies'];
$topic_replies_real = $topic_data['topic_replies_real'];
$forum_id = $topic_data['forum_id'];
$topic_id = $topic_data['topic_id'];
$forum_name = $topic_data['forum_name'];
$topic_last_post_id = $topic_data['topic_last_post_id'];
$topic_last_post_time = $topic_data['topic_last_post_time'];
$topic_last_poster_name = $topic_data['topic_last_poster_name'];
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $topic_replies_real : $topic_replies;
$start = floor(($replies) / $config['posts_per_page']) * $config['posts_per_page'];
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
if ( empty($phpbb_seo->seo_url['topic'][$topic_id]) ) {
if ($line[$i]['topic_type'] == POST_GLOBAL) {
$phpbb_seo->seo_opt['topic_type'][$topic_id] = POST_GLOBAL;
}
$phpbb_seo->seo_censored[$topic_id] = $topic_title;
$phpbb_seo->seo_url['topic'][$topic_id] = $phpbb_seo->format_url($phpbb_seo->seo_censored[$topic_id]);
}
if ( empty($phpbb_seo->seo_url['forum'][$forum_id]) ) {
$phpbb_seo->seo_url['forum'][$forum_id] = $phpbb_seo->set_url($line[$i]['forum_name'], $forum_id, $phpbb_seo->seo_static['forum']);
}
// www.phpBB-SEO.com SEO TOOLKIT END
$post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id . '&f=' . $forum_id . '&start=' . $start ) . '#p' . $topic_last_post_id;
$topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id . '&f=' . $forum_id );
//On affiche
echo '<li><a href="'.$topic_url.'">'.$topic_title.'</a> - '.$forum_name.' - <a rel="nofollow" href="'.$post_url.'">Dernier message par '.$topic_last_poster_name.'</a> - '.strftime('%d/%m/%y ',$topic_last_post_time).' à '.strftime('%H:%M ',$topic_last_post_time).'</li>';
}
$db->sql_freeresult($result);
?>
Si quelqu'un pouvait m'aider... merci beaucoup!

Français |
Anglais

