| |
|
| :: |
| Auteur |
Message |
furet
Inscrit le: 22 Juil 2008 Messages: 2
|
Posté le: Mar Juil 22, 2008 10:13 am Sujet du message: Joomla module last topic avec URL rewrités |
|
|
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: |
<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 . '&f=' . $forum_id . '&start=' . $start ) . '#p' . $post_id;
$topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&start=$start");
echo '<a href="' . $post_url . '">recent post</a> to "';
echo '<a href="'. $topic_url .'">'. $topic_title .'</a>"<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: |
<?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 . '&f=' . $forum_id . '&start=' . $start ) . '#p' . $post_id;
$topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&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 ! |
|
|
| Revenir en haut de page |
|
 |
|
 |
dcz Administrateur - Site Admin

Inscrit le: 28 Avr 2006 Messages: 15122
|
|
| Revenir en haut de page |
|
 |
furet
Inscrit le: 22 Juil 2008 Messages: 2
|
Posté le: Mar Juil 22, 2008 12:46 pm Sujet du message: Re: Joomla module last topic avec URL rewrités |
|
|
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/';
| Citation: |
<?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 . '&f=' . $forum_id . '&start=' . $start ) . '#p' . $post_id;
$topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&start=$start");
echo '<li><a href="' . $topic_url. '">' . $topic_title . ' (' . $replies . ')</a></li>';
}
// Ending the output
echo "</ul>";
?>
|
|
|
|
| Revenir en haut de page |
|
 |
|
| Navigation |
Autres sujets de discussion |
|
|
|
|
|
|
|