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  
 
   
rewriting topic title

 
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB Forum
::  
Author Message
swiety



Joined: 11 Mar 2008
Posts: 9

rewriting topic titlePosted: Mon Aug 11, 2008 3:57 pm    Post subject: rewriting topic title

Hi!
I have implemented recent topics table on forum index and what I need is to rewrite topics titles there.
I have mod rewrite advanced installed and it works OK. I've been trying to add sth silimiar like the code in viewforum, but no effect.

This is the code of this mod placed on index.php:
Code:
//------------------------------------------------------------------------
// Top Topics on Index 1.1.0 - Begin Code Addition
//
   $template->assign_vars(array(
      'L_TOPICSRECENT' => $lang['TopicsRecent'],
      'L_TOPICSPOPULAR' => $lang['TopicsPopular'],
      'L_TOPICSPOPULARVIEW' => $lang['TopicsPopularView'])
   );

   // Get forum auth information to insure privacy of hidden topics
   $topics_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $userdata);
   $topics_auth_sql = '';
   foreach($topics_auth as $k=>$v)
   {
      if( $v['auth_view'] && $v['auth_read'] )
      {
         $topics_auth_sql .= (( empty($topics_auth_sql) ) ? '': ', ') . $k;
      }
   }

   if( empty($topics_auth_sql) )
   {
      $template->assign_block_vars('topicrecentpopular', array(
         'TOPICSPOPULAR' => $lang['No_Posts'],
         'TOPICSPOPULARVIEW' => $lang['No_Posts'],
         'TOPICSRECENT' => $lang['No_Posts']
      ));
   }
   else
   {
      //
      // Okay, let's build the topic recent and popular
      //
      $active_topics_sql = 'SELECT t.topic_id, t.topic_title, t.topic_replies, t.topic_views, t.topic_last_post_id
         FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE. ' f
         WHERE t.forum_id IN (' . $topics_auth_sql . ')
            AND f.forum_id = t.forum_id
         ORDER BY %1$s DESC
         LIMIT 0,5';
      $active_topics_sql_a = sprintf($active_topics_sql, 'topic_last_post_id');
      $active_topics_sql_b = sprintf($active_topics_sql, 'topic_replies');
      $active_topics_sql_c = sprintf($active_topics_sql, 'topic_views');
      $recent_row = $popular_row = $viewed_row = array();

      if( !$active_topics_a = $db->sql_query($active_topics_sql_a))
      {
         message_die(GENERAL_ERROR, 'Could not retrieve recent topics', '', __LINE__, __FILE__, $active_topics_sql_a);
      }
      $recent_row = $db->sql_fetchrowset($active_topics_a);
      $db->sql_freeresult($active_topics_a);

      if( !$active_topics_b = $db->sql_query($active_topics_sql_b))
      {
         message_die(GENERAL_ERROR, 'Could not retrieve popular topics', '', __LINE__, __FILE__, $active_topics_sql_b);
      }
      $popular_row = $db->sql_fetchrowset($active_topics_b);
      $db->sql_freeresult($active_topics_b);

      if( !$active_topics_c = $db->sql_query($active_topics_sql_c))
      {
         message_die(GENERAL_ERROR, 'Could not retrieve most viewed topics', '', __LINE__, __FILE__, $active_topics_sql_c);
      }
      $viewed_row = $db->sql_fetchrowset($active_topics_c);
      $db->sql_freeresult($active_topics_c);

      for( $i = 0; $i < 5; $i++ )
      {
         $recent_topic_title = $recent_row[$i]['topic_title'];
         $popular_topic_title = $popular_row[$i]['topic_title'];
         $viewed_topic_title = $viewed_row[$i]['topic_title'];

         if( strlen($recent_topic_title) > 40 )
         {
            $recent_topic_title = substr($recent_topic_title, 0, 40) . '...';
         }

         if( strlen($popular_topic_title) > 40 )
         {
            $popular_topic_title = substr($popular_topic_title, 0, 40) . '...';
         }

         if( strlen($viewed_topic_title) > 40 )
         {
            $viewed_topic_title = substr($viewed_topic_title, 0, 40) . '...';
         }

         $recent_post = '<a href="viewtopic.php?' . POST_TOPIC_URL . '=' . $recent_row[$i]['topic_id'] . '" title="' . $recent_row[$i]['topic_title'] . '">' . $recent_topic_title . '</a>';
         $popular_post = '<a href="viewtopic.php?' . POST_TOPIC_URL . '=' . $popular_row[$i]['topic_id'] . '" title="' . $popular_row[$i]['topic_title'] . '">' . $popular_topic_title . '</a>';
         $popular_total_replies = $popular_row[$i]['topic_replies'];
         $viewed_post = '<a href="viewtopic.php?' . POST_TOPIC_URL . '=' . $viewed_row[$i]['topic_id'] . '" title="' . $viewed_row[$i]['topic_title'] . '">' . $viewed_topic_title . '</a>';
         $viewed_total_replies = $viewed_row[$i]['topic_views'];

         $template->assign_block_vars('topicrecentpopular', array(
            'TOPICSPOPULAR' => $popular_post,
            'TOPICSPOPULARC' => $popular_total_replies,
            'TOPICSPOPULARVIEW' => $viewed_post,
            'TOPICSPOPULARVIEWC' => $viewed_total_replies,
            'TOPICSRECENT' => $recent_post)
         );
      }
   }
//
// Top Topics on Index 1.1.0 - End Code Addition
//------------------------------------------------------------------------


Thanks in advance.
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 15242

rewriting topic titlePosted: Wed Aug 13, 2008 1:12 pm    Post subject: Re: rewriting topic title

Try adding :

Code:
         // www.phpBB-SEO.com SEO TOOLKIT BEGIN
         if (empty($phpbb_seo->seo_url['topic'][$recent_row[$i]['topic_id']]) ) {
                  $phpbb_seo->seo_url['topic'][$recent_row[$i]['topic_id']] = $phpbb_seo->format_url($recent_topic_title);
         }
         if (empty($phpbb_seo->seo_url['topic'][$popular_row[$i]['topic_id']]) ) {
                  $phpbb_seo->seo_url['topic'][$popular_row[$i]['topic_id']] = $phpbb_seo->format_url($popular_topic_title);
         }
         if (empty($phpbb_seo->seo_url['topic'][$viewed_row[$i]['topic_id']]) ) {
                  $phpbb_seo->seo_url['topic'][$viewed_row[$i]['topic_id']] = $phpbb_seo->format_url($viewed_topic_title);
         }
         // www.phpBB-SEO.com SEO TOOLKIT END



after :

Code:
         $recent_topic_title = $recent_row[$i]['topic_title'];
         $popular_topic_title = $popular_row[$i]['topic_title'];
         $viewed_topic_title = $viewed_row[$i]['topic_title'];


++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
swiety



Joined: 11 Mar 2008
Posts: 9

rewriting topic titlePosted: Sun Aug 24, 2008 7:05 pm    Post subject: Re: rewriting topic title

Unfortunately this solution doesn't work Confused
There is no effect after adding that code..
Url still looks like viewtopic.php?t=xxx and it should topic-title-txxx.html as it is provided by mod rewrite advanced.

The mod I'm using is localted HERE. If it at all would be possible, please try to install it (takes about 3 minutes) and maybe you would devise sth else working with this code.
I think you (as the author of adv mod rewrite) are the one who may help me with this issue.
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 15242

rewriting topic titlePosted: Wed Aug 27, 2008 9:49 am    Post subject: Re: rewriting topic title

oh yes, we need to use append_sid as well, replace :
Code:
         $recent_post = '<a href="viewtopic.php?' . POST_TOPIC_URL . '=' . $recent_row[$i]['topic_id'] . '" title="' . $recent_row[$i]['topic_title'] . '">' . $recent_topic_title . '</a>';
         $popular_post = '<a href="viewtopic.php?' . POST_TOPIC_URL . '=' . $popular_row[$i]['topic_id'] . '" title="' . $popular_row[$i]['topic_title'] . '">' . $popular_topic_title . '</a>';
         $popular_total_replies = $popular_row[$i]['topic_replies'];
         $viewed_post = '<a href="viewtopic.php?' . POST_TOPIC_URL . '=' . $viewed_row[$i]['topic_id'] . '" title="' . $viewed_row[$i]['topic_title'] . '">' . $viewed_topic_title . '</a>';


with :

Code:
         $recent_post = '<a href="' . append_sid($phpbb_root_path . 'viewtopic.php?' . POST_TOPIC_URL . '=' . $recent_row[$i]['topic_id']) . '" title="' . $recent_row[$i]['topic_title'] . '">' . $recent_topic_title . '</a>';
         $popular_post = '<a href="' . append_sid($phpbb_root_path . 'viewtopic.php?' . POST_TOPIC_URL . '=' . $popular_row[$i]['topic_id']) . '" title="' . $popular_row[$i]['topic_title'] . '">' . $popular_topic_title . '</a>';
         $popular_total_replies = $popular_row[$i]['topic_replies'];
         $viewed_post = '<a href="' . append_sid($phpbb_root_path . 'viewtopic.php?' . POST_TOPIC_URL . '=' . $viewed_row[$i]['topic_id']) . '" title="' . $viewed_row[$i]['topic_title'] . '">' . $viewed_topic_title . '</a>';


should do it.

++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
swiety



Joined: 11 Mar 2008
Posts: 9

rewriting topic titlePosted: Sun Sep 07, 2008 1:13 pm    Post subject: Re: rewriting topic title

Adding append_sid has helped Wink
Works great. Thanks.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB Forum
Page 1 of 1

Navigation Similar Topics

Jump to: