Joomla module last topic avec URL rewrités

Support et discussions sur les différentes téchniques de réécriture d'url (url rewriting) pour phpBB3 - Olympus.

Modérateur: Modérateurs

Joomla module last topic avec URL rewrités

Messagede furet » Mar Juil 22, 2008 10:13 am

Bonjour

Suite au différents post du forum j'essaie de créer un module joomla qui prend en compte la réécriture d'URL (c'est plus propre que le 301 du noduplicate !).
Le code standalone ci dessous fonctionne parfaitement :

Code: Tout sélectionner
<html>
<body>

<?php

// recent topics "lite" - modify configuration variable below
$public_forums = "1,2,3,4,5,6,7,8,9"; // list of public forums

// usual initialization variables
define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

$sql = "SELECT DISTINCT(t.topic_id), t.forum_id, t.topic_title, t.topic_last_post_id, t.topic_status, t.topic_replies, t.topic_replies_real, t.topic_type, f.forum_name
   FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
   WHERE t.forum_id IN ($public_forums)
   AND t.topic_status <> 2
   AND t.forum_id = f.forum_id
   ORDER BY t.topic_last_post_id DESC LIMIT 10";   

$result = $db->sql_query($sql);

$line = array();
while( $row = $db->sql_fetchrow($result)) {
   $line[] = $row;
}
$db->sql_freeresult($result);

for( $i = 0; $i < count($line); $i++ )
{
   $forum_name = $line[$i]['forum_name'];
   $topic_id = $line[$i]['topic_id'];
   $forum_id = $line[$i]['forum_id'];
   $post_id = $line[$i]['topic_last_post_id'];
   $topic_title = censor_text($line[$i]['topic_title']);
   
   $replies = ($auth->acl_get('m_approve', $forum_id)) ? $line[$i]['topic_replies_real'] : $line[$i]['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 . '&amp;f=' . $forum_id . '&amp;start=' . $start ) . '#p' . $post_id;
   $topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start");       

   echo '<a href="' . $post_url . '">recent post</a> to &quot;';     
   echo '<a href="'. $topic_url .'">'. $topic_title .'</a>&quot;<br/>';
}

?>

</body>
</html>


néanmoins, quand je l'adapte en code JOOMLA de type module et en rajoutant un global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template, $_SID, $_EXTRA_URL, $auth; les sujets s'affichent sauf que les URLs ne sont pas rewrités ... J'ai l'impression qu'il manque des variables initialisées ou il y a un conflit kkpart :
Code: Tout sélectionner
<?php
/**
* @version      $Id: mod_phpbb3_latest_topics.php 8813 2007-Dec-14 1:32:56 iapostolov $
* @packages   Joomla / phpBB3 /
* @copyright   Copyright (C)  200 sylv.
* @author      sylv
* @website      http://www.xxx.com
* @e-mail      xxx@yyy.com
* @license      GNU/GPL v2.0
*/

// no direct access
defined('_JEXEC') or die('Restricted access');
define('IN_PHPBB', true);
global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template, $_SID, $_EXTRA_URL, $auth;


// load the module parameters      

$phpbb3_post_count         = $params->get('phpbb3_post_count', 10);      

// Load the database settings frot he phpBB configuration
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

// starting the module output      
echo "<ul class='forum_topics'>";
            
// Load the last topics
   $sql = "SELECT DISTINCT(t.topic_id), t.forum_id, t.topic_title, t.topic_last_post_id, t.topic_status, t.topic_replies, t.topic_replies_real, t.topic_type, f.forum_name
   FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
   WHERE t.topic_status <> 2
   AND t.forum_id = f.forum_id
   ORDER BY t.topic_last_post_id DESC LIMIT 10";   

$result = $db->sql_query($sql);

$line = array();
while( $row = $db->sql_fetchrow($result)) {
   $line[] = $row;
}
$db->sql_freeresult($result);

for( $i = 0; $i < count($line); $i++ )
{
   $forum_name = $line[$i]['forum_name'];
   $topic_id = $line[$i]['topic_id'];
   $forum_id = $line[$i]['forum_id'];
   $post_id = $line[$i]['topic_last_post_id'];
   $topic_title = censor_text($line[$i]['topic_title']);
   
   $replies = ($auth->acl_get('m_approve', $forum_id)) ? $line[$i]['topic_replies_real'] : $line[$i]['topic_replies'];   
   $start = floor(($replies) / $config['posts_per_page']) * $config['posts_per_page'];
   
   print_r($phpbb_seo->seo_url['topic'][$topic_id]);
   print_r($phpbb_seo->seo_url['forum'][$forum_id]);
   
   // 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 . '&amp;f=' . $forum_id . '&amp;start=' . $start ) . '#p' . $post_id;
   $topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start");
   echo '<li><a href="' . $topic_url. '">' . $topic_title . ' (' . $replies . ')</a></li>';     
   }
// Ending the output
echo "</ul>";

?>


Je débute en PHP alors merci pour votre aide !
furet
 
Messages: 2
Inscription: Mar Juil 22, 2008 10:05 am

Publicité

Messagede dcz » Mar Juil 22, 2008 12:15 pm

Il est en fait bien plus coton de mélanger les deux codes vu qu'il y a des chances que certain noms de variable soient redondant entre les deux scripts.

La solution la plus simple est de le faire en utilisant les flux de GYM sitemaps, on en parle .

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Messages: 21407
Inscription: Ven Avr 28, 2006 9:03 pm

Messagede furet » Mar Juil 22, 2008 12:46 pm

Bon ben j'ai trouvé il me manquait un global $phpbb_seo
voic un code qui fonctionne sous joomla 1.5 :
attention à adapter le : $phpbb_root_path = './forum/';

<?php
/**
* @version $Id: mod_phpbb3_latest_topics.php 8813
*/

// no direct access
defined('_JEXEC') or die('Restricted access');
define('IN_PHPBB', true);
global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template, $_SID, $_EXTRA_URL, $auth, $phpbb_hook, $phpbb_seo;



// load the module parameters

$phpbb3_post_count = $params->get('phpbb3_post_count', 10);

// Load the database settings frot he phpBB configuration
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

// starting the module output
echo "<ul class='forum_topics'>";

// Load the last topics
$sql = "SELECT DISTINCT(t.topic_id), t.forum_id, t.topic_title, t.topic_last_post_id, t.topic_status, t.topic_replies, t.topic_replies_real, t.topic_type, f.forum_name
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
WHERE t.topic_status <> 2
AND t.forum_id = f.forum_id
ORDER BY t.topic_last_post_id DESC LIMIT 10";

$result = $db->sql_query($sql);

$line = array();
while( $row = $db->sql_fetchrow($result)) {
$line[] = $row;
}
$db->sql_freeresult($result);

for( $i = 0; $i < count($line); $i++ )
{
$forum_name = $line[$i]['forum_name'];
$topic_id = $line[$i]['topic_id'];
$forum_id = $line[$i]['forum_id'];
$post_id = $line[$i]['topic_last_post_id'];
$topic_title = censor_text($line[$i]['topic_title']);

$replies = ($auth->acl_get('m_approve', $forum_id)) ? $line[$i]['topic_replies_real'] : $line[$i]['topic_replies'];
$start = floor(($replies) / $config['posts_per_page']) * $config['posts_per_page'];

print_r($phpbb_seo->seo_url['topic'][$topic_id]);
print_r($phpbb_seo->seo_url['forum'][$forum_id]);

// 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 . '&amp;f=' . $forum_id . '&amp;start=' . $start ) . '#p' . $post_id;
$topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;start=$start");
echo '<li><a href="' . $topic_url. '">' . $topic_title . ' (' . $replies . ')</a></li>';
}
// Ending the output
echo "</ul>";

?>








furet
 
Messages: 2
Inscription: Mar Juil 22, 2008 10:05 am


Retourner vers mod Rewrite phpBB

 


  • Articles en relation
    Réponses
    Vus
    Dernier message

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 7 invités