phpBB SEO
Boards
Directory  
SEO  
Downloads
  phpBB SEO : Search Engine Optimization, Directory, Forums  
Index
Forums
Annuaire
Référencement
Télécharger
 
  Search Rechercher
    Register
Username :  Password :  Log me on automatically each visit  
S'enregistrer  
 
   
Function Last Topic
Goto page 1, 2  Next
 
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB3 mod Rewrite  » Advanced SEO URL
::  
Author Message
psaico



Joined: 14 May 2008
Posts: 35

Function Last TopicPosted: 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 . '&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/>';
}
}
ShowLastTopic(2,10);
?>


Why?
Surprised
Back to top
SeO
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 15 Mar 2006
Posts: 3987

Function Last TopicPosted: Sun May 25, 2008 12:21 pm    Post subject: Re: Function Last Topic

The phpbb_seo object needs to be globalized into functions, add :

Code:
global $phpbb_seo;


after :

Code:
function ShowLastTopic($id,$limit){


And you'll be able to manipulate the class in your function Wink

_________________
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

Function Last TopicPosted: 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

Sad
Back to top
SeO
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 15 Mar 2006
Posts: 3987

Function Last TopicPosted: 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 :
Code:
ob_end_flush();


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

Function Last TopicPosted: 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
Administrateur - Site Admin


Joined: 15 Mar 2006
Posts: 3987

Function Last TopicPosted: Sun May 25, 2008 1:24 pm    Post subject: Re: Function Last Topic

mm, what about your common.php file, does it actually start the phpbb_seo class, is the mod installed on the forum you're connecting this script to ?

_________________
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

Function Last TopicPosted: 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();
#
}


Rolling Eyes
Back to top
SeO
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 15 Mar 2006
Posts: 3987

Function Last TopicPosted: Sun May 25, 2008 2:09 pm    Post subject: Re: Function Last Topic

Anything shows up if you add :

var_dump($phpbb_seo);

after this code in common.php for a sec ?

_________________
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

Function Last TopicPosted: Sun May 25, 2008 2:16 pm    Post subject: Re: Function Last Topic

Look the output on source code in this page:
http://www.big-bug.net/forum/index.php

the output is in <!-- -->

Thx .
Back to top
SeO
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 15 Mar 2006
Posts: 3987

Function Last TopicPosted: Sun May 25, 2008 2:19 pm    Post subject: Re: Function Last Topic

Are you using this script on phpbb's index ?

Looks like meant to be used on pages that do not share phpbb's code.

Various solutions already exist to display last posts on phpBB's index as well as on other pages, have you given search a try ?

_________________
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

Function Last TopicPosted: Sun May 25, 2008 2:24 pm    Post subject: Re: Function Last Topic

No, i used on homepage.. but not in homepage forum Sad
Back to top
psaico



Joined: 14 May 2008
Posts: 35

Function Last TopicPosted: Thu May 29, 2008 8:17 am    Post subject: Re: Function Last Topic

up Sad
Back to top
psaico



Joined: 14 May 2008
Posts: 35

Function Last TopicPosted: 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 . '&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/>';
   }
}
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? Confused
Back to top
SeO
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 15 Mar 2006
Posts: 3987

Function Last TopicPosted: Fri May 30, 2008 8:08 am    Post subject: Re: Function Last Topic

Try to globalise $phpbb_root_path in your function and eventually to set it outside of it.

_________________
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

Function Last TopicPosted: Fri May 30, 2008 8:19 am    Post subject: Re: Function Last Topic

Oh yeahhhhhh!
it work Smile Smile


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? Wink
Back to top
Display posts from previous:   
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB3 mod Rewrite  » Advanced SEO URL
Page 1 of 2 Goto page 1, 2  Next

Navigation Similar Topics

Jump to: