| :: |
| Author |
Message |
psaico

Joined: 14 May 2008 Posts: 35
|
Posted: Sun May 25, 2008 10:38 am Post subject: Function Last Topic |
|
|
Hi guys..
Error:
| Code: |
Fatal error: Call to a member function on a non-object in /home/mhd-01/www.big-bug.net/htdocs/forum/includes/cache.php on line 51
|
Functions:
| Code: |
<?php
function ShowLastTopic($id,$limit){
ob_start();
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
ob_end_flush();
// 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 = $id
AND t.topic_status <> 2
AND t.forum_id = f.forum_id
ORDER BY t.topic_last_post_id DESC LIMIT $limit";
$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/>';
}
}
ShowLastTopic(2,10);
?>
|
Why?
 |
|
|
| Back to top |
|
 |
|
 |
SeO Administrateur - Site Admin

Joined: 15 Mar 2006 Posts: 3987
|
|
| Back to top |
|
 |
psaico

Joined: 14 May 2008 Posts: 35
|
Posted: Sun May 25, 2008 12:32 pm Post subject: Re: Function Last Topic |
|
|
UHm, thanks..
but don't work.. i receive the same error.
I have try with
| Code: |
function ShowLastTopic($id,$limit){
global $phpbb_seo;
var_dump($phpbb_seo);
return;
code ..
code ..
|
and $phpbb_seo is NULL
 |
|
|
| Back to top |
|
 |
SeO Administrateur - Site Admin

Joined: 15 Mar 2006 Posts: 3987
|
Posted: Sun May 25, 2008 12:36 pm Post subject: Re: Function Last Topic |
|
|
Of course, this assumes that the phbb_seo class was started before, which should here be the case since common.php is included. The phpbb_seo class should thus be accessible.
try :
| Code: | | var_dump($phpbb_seo); |
after :
To see if you get something. |
_________________ phpBB SEO || SEO Forum || Forum Référencement
GYM Sitemap & RSS for phpBB3 has been released ! || GYM Sitemap & RSS for phpBB3 est disponible ! |
|
| Back to top |
|
 |
psaico

Joined: 14 May 2008 Posts: 35
|
Posted: Sun May 25, 2008 12:44 pm Post subject: Re: Function Last Topic |
|
|
| Code: |
function ShowLastTopic($id,$limit){
global $phpbb_seo;
ob_start();
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
ob_end_flush();
var_dump($phpbb_seo);
return;
some code..
|
mmm nothing ..
| Code: |
Fatal error: Call to a member function on a non-object in /home/mhd-01/www.big-bug.net/htdocs/forum/includes/cache.php on line 51 |
|
|
|
| Back to top |
|
 |
SeO Administrateur - Site Admin

Joined: 15 Mar 2006 Posts: 3987
|
|
| Back to top |
|
 |
psaico

Joined: 14 May 2008 Posts: 35
|
Posted: Sun May 25, 2008 1:41 pm Post subject: Re: Function Last Topic |
|
|
I have installed phpbb-seo
and in my common.php there is this part of code
| Code: |
#
if (empty($phpbb_seo) ) {
#
require_once($phpbb_root_path . 'phpbb_seo/phpbb_seo_class.'.$phpEx);
#
$phpbb_seo = new phpbb_seo();
#
}
|
 |
|
|
| Back to top |
|
 |
SeO Administrateur - Site Admin

Joined: 15 Mar 2006 Posts: 3987
|
|
| Back to top |
|
 |
psaico

Joined: 14 May 2008 Posts: 35
|
|
| Back to top |
|
 |
SeO Administrateur - Site Admin

Joined: 15 Mar 2006 Posts: 3987
|
|
| Back to top |
|
 |
psaico

Joined: 14 May 2008 Posts: 35
|
Posted: Sun May 25, 2008 2:24 pm Post subject: Re: Function Last Topic |
|
|
No, i used on homepage.. but not in homepage forum  |
|
|
| Back to top |
|
 |
psaico

Joined: 14 May 2008 Posts: 35
|
Posted: Thu May 29, 2008 8:17 am Post subject: Re: Function Last Topic |
|
|
up  |
|
|
| Back to top |
|
 |
psaico

Joined: 14 May 2008 Posts: 35
|
Posted: Fri May 30, 2008 6:48 am Post subject: Re: Function Last Topic |
|
|
Ok, now it work:
| Code: |
<?php
function GetTopic($forum_id,$limit,$order_by){
global $db,$auth,$phpbb_seo,$config,$phpEx,$user,$cache,$template;
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);
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 = $forum_id
AND t.topic_status <> 2
AND t.forum_id = f.forum_id
ORDER BY $order_by DESC LIMIT $limit";
$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'];
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']);
}
$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/>';
}
}
GetTopic(2,55,"topic_time");
?>
|
But i call the functions in the directory / and not in /forum/ i receive this error:
| Code: |
[phpBB Debug] PHP Notice: in file /Users/duccio/Sites/bigbug3/forum/includes/utf/utf_tools.php on line 1776: include(/forum/includes/utf/utf_normalizer.php) [function.include]: failed to open stream: No such file or directory
[phpBB Debug] PHP Notice: in file /Users/duccio/Sites/bigbug3/forum/includes/utf/utf_tools.php on line 1776: include() [function.include]: Failed opening '/forum/includes/utf/utf_normalizer.php' for inclusion (include_path='.:/Applications/xampp/xamppfiles/lib/php')
Fatal error: Class 'utf_normalizer' not found in /Users/duccio/Sites/bigbug3/forum/includes/utf/utf_tools.php on line 1781
|
Ideas?  |
|
|
| Back to top |
|
 |
SeO Administrateur - Site Admin

Joined: 15 Mar 2006 Posts: 3987
|
|
| Back to top |
|
 |
psaico

Joined: 14 May 2008 Posts: 35
|
Posted: Fri May 30, 2008 8:19 am Post subject: Re: Function Last Topic |
|
|
Oh yeahhhhhh!
it work
edit:
if i call two times the function i receive this error:
| Code: |
Fatal error: Cannot redeclare deregister_globals() (previously declared in /Users/duccio/Sites/bigbug3/forum/common.php:32) in /Users/duccio/Sites/bigbug3/forum/common.php on line 94 |
ideas?  |
|
|
| Back to top |
|
 |
|
|