PHPbb3 Seo Advanced Mod, Creating titles

Support for the phpBB3 SEO mods released in the phpBB3 SEO Toolikt forum.

Moderator: Moderators


PHPbb3 Seo Advanced Mod, Creating titles

Postby splitice » Thu Mar 20, 2008 1:46 am

I was just wondering if there is any easy way of generating the urls to access threads using php. I have already converted all the other types of urls, just the threads one.

The format I am using if it helps is /forum/topic-t99/ if it helps

Thanks in advance,
Splitice
splitice
 
Posts: 4
Joined: Sat Mar 15, 2008 11:17 pm

Advertisement

Re: PHPbb3 Seo Advanced Mod, Creating titles

Postby HB » Fri Mar 21, 2008 3:56 am

splitice wrote:I was just wondering if there is any easy way of generating the urls to access threads using php.

Err, could you be a little more vague? :lol:

Seriously... Would you elaborate on what you want to do? Sure, you can model your code after the code in the premod, it is all marked with:

Code: Select all
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
...
// www.phpBB-SEO.com SEO TOOLKIT END
Dan Kehn
HB
phpBB SEO Team
phpBB SEO Team
 
Posts: 1019
Joined: Mon Oct 16, 2006 2:25 am

Postby splitice » Fri Mar 21, 2008 5:03 am

sorry for being vauge basicly I want to know if there is a function that will make the URL for viewtopic from the topicid.

Its really hard to explain so basicly I have my sitemap
-http://usharez.com/sitemap.xml

and then an individual forums sitemap

-http://usharez.com/forum-179.xml

I want to change the urls like -http://usharez.com/viewtopic.php?f=179&t=26069 to be phpbb3 SEO URLS
splitice
 
Posts: 4
Joined: Sat Mar 15, 2008 11:17 pm

Postby HB » Fri Mar 21, 2008 2:30 pm

Sorry, I'm not getting a much clearer picture. :?

You can obviously model your code after the URL remapping code from viewtopic.php. Basically the code set off by "// www.phpBB-SEO.com SEO TOOLKIT BEGIN/END" caches the topic title to ID mapping, forum title to ID mapping, etc. in the $phpbb_seo class instance and then the code in append_sid calls format_url (or similar method). You could call $phpbb_seo methods directly; all the "setup" code you see in viewtopic.php etc. is to enable append_sid to do the URL remapping; this approach was chosen because phpBB has the convention that every single forum URL passes by append_sid, thereby enabling a single location for the remapping invocations.

Without more details (code snippets), I cannot advise you further. Reviewing the code noted above should answer your questions.
Dan Kehn
HB
phpBB SEO Team
phpBB SEO Team
 
Posts: 1019
Joined: Mon Oct 16, 2006 2:25 am

Postby splitice » Sat Mar 22, 2008 12:31 am

sorry im not a good explainer when it comes to using terms.

Anyway heres the code of google-sitemap.php
Code: Select all
<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* @author Tobi Schäfer http://www.seo-phpbb.org/
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.'.$phpEx);

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

$domain_root = generate_board_url() . '/';

if (isset($_GET['fid']))
{
   if (is_numeric($_GET['fid']))
   {
      $fid = $_GET['fid'];
   }
}

echo header('Content-Type: text/xml; charset=utf-8');

if (isset($fid))
{
   echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
   echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";

   $sql = 'SELECT  forum_topics, forum_id, forum_name FROM ' . FORUMS_TABLE . '
         WHERE forum_id = "' . (int) $fid . '"';
   $result = $db->sql_query($sql);
   $forum_data = $db->sql_fetchrow($result);
   // Forums
   echo '<url>' . "\n";
   echo '   <loc>' . $domain_root .$phpbb_seo->format_url($forum_data['forum_name']).'-f' . $forum_data['forum_id'] . '</loc>' . "\n";
   echo '   <changefreq>hourly</changefreq>'. "\n";
   echo '</url>' . "\n";

   // Forums with more that 1 page
   if ( $forum_data['forum_topics'] > $config['topics_per_page'] )
   {
      $s = 0;
      $pages = $forum_data['forum_topics'] / $config['topics_per_page'];
      for ($i = 1; $i < $pages; $i++)
      {
         $s = $s + $config['topics_per_page'];
         echo '<url>' . "\n";
   echo '   <loc>' . $domain_root .$phpbb_seo->format_url($forum_data['forum_name']).'-f' . $forum_data['forum_id'] . '/page'.$s.'.html</loc>' . "\n";
         //echo '   <loc>' . $domain_root .  'viewforum.' . $phpEx . '?f=' . $forum_data['forum_id'] . '&amp;start=' . $s . '</loc>' . "\n";
         echo '   <changefreq>hourly</changefreq>' . "\n";
         echo '</url>' . "\n";
      }
   }

   if ($forum_data['forum_id'] == $fid)
   {
      $sql = 'SELECT t.topic_title, t.topic_replies, t.topic_last_post_id, t.forum_id, t.topic_type, t.topic_id, p.post_time, p.post_id
            FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
            WHERE t.forum_id = ' . $fid . '
               AND p.post_id = t.topic_last_post_id
            ORDER BY t.topic_type DESC, t.topic_last_post_id DESC';
      $result = $db->sql_query($sql);

      while ($data = $db->sql_fetchrow($result))
      {
         // Topics
         echo '<url>' . "\n";
         //echo '   <loc>' . $domain_root . 'viewtopic.' . $phpEx . '?f=' . $forum_data['forum_id'] . '&amp;t=' . $data['topic_id'] . '</loc>' . "\n";
   echo '   <loc>' . $domain_root . 'viewtopic.' . $phpEx . '?f=' . $forum_data['forum_id'] . '&amp;t=' . $data['topic_id'] . '</loc>' . "\n";
         echo '   <lastmod>'. date('Y-m-d', $data['post_time']),'</lastmod>' . "\n";
         echo '</url>' . "\n";

         // Topics with more that 1 Page
         if ( $data['topic_replies'] > $config['posts_per_page'] )
         {
            $s = 0;
            $pages = $data['topic_replies'] / $config['posts_per_page'];

            for ($i = 1; $i < $pages; $i++)
            {
               $s = $s + $config['posts_per_page'];
               echo '<url>' . "\n";
               echo '   <loc>' . $domain_root . 'viewtopic.' . $phpEx . '?f=' . $forum_data['forum_id'] . '&amp;t=' . $data['topic_id'] . '&amp;start=' . $s . '</loc>' . "\n";
               echo '   <lastmod>' . date('Y-m-d', $data['post_time']),'</lastmod>' . "\n";
               echo '</url>' . "\n";
            }
         }
      }
   }
   echo '</urlset>';
}
else
{
   echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
   echo '  <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
   
   $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE;
   $result = $db->sql_query($sql);

   while($data = $db->sql_fetchrow($result))
   {
      if ($auth->acl_get('f_list', $data['forum_id']))
      {
         echo '    <sitemap>' . "\n";
         echo '       <loc>'. $domain_root . 'forum-' . $data['forum_id'] . '.xml</loc>' . "\n";
         // google sitemap error
         //echo '       <changefreq>hourly</changefreq>'. "\n";
         echo '    </sitemap>'. "\n";
      }
   }
   echo "\n".'  </sitemapindex>';
}

?>

and .htaccess
Code: Select all
    # Lines That should already be in your .htacess
    <Files "config.php">
    Order Allow,Deny
    Deny from All
    </Files>
    <Files "common.php">
    Order Allow,Deny
    Deny from All
    </Files>

    # You may need to un-comment the following line
    # Options +FollowSymlinks
    # REMEBER YOU ONLY NEED TO STARD MOD REWRITE ONCE
    RewriteEngine On
    # REWRITE BASE
    RewriteBase /
    # HERE IS A GOOD PLACE TO ADD THE WWW PREFIXE REDIRECTION

RewriteCond %{REQUEST_URI} /sitemap.xml
RewriteRule (.*) /google-sitemap.php  [L]

RewriteCond %{REQUEST_URI} /forum-([0-9]+).xml
RewriteRule (.*) /google-sitemap.php?fid=%1  [L]

    #####################################################
    # PHPBB SEO REWRITE RULES - ADVANCED
    #####################################################
    # AUTHOR : dcz www.phpbb-seo.com
    # STARTED : 01/2006
    #################################
    # FORUMS PAGES
    ###############
    # FORUM INDEX REWRITERULE WOULD STAND HERE IF USED. 'forum' REQUIRES TO BE SET AS FORUM INDEX
    # RewriteRule ^forum\.html$ /index.php [QSA,L,NC]
    # FORUM
    RewriteRule ^[a-z0-9_-]*-f([0-9]+)/?(page([0-9]+)\.html)?$ /viewforum.php?f=$1&start=$3 [QSA,L,NC]
    # TOPIC WITH VIRTUAL FOLDER
    RewriteRule ^[a-z0-9_-]*-f([0-9]+)/[a-z0-9_-]*-t([0-9]+)(-([0-9]+))?\.html$ /viewtopic.php?f=$1&t=$2&start=$4 [QSA,L,NC]
    # GLOBAL ANNOUNCES WITH VIRTUAL FOLDER
    RewriteRule ^announces/[a-z0-9_-]*-t([0-9]+)(-([0-9]+))?\.html$ /viewtopic.php?t=$1&start=$3 [QSA,L,NC]
    # TOPIC WITHOUT FORUM ID & DELIM
    RewriteRule ^[a-z0-9_-]*/?[a-z0-9_-]*-t([0-9]+)(-([0-9]+))?\.html$ /viewtopic.php?t=$1&start=$3 [QSA,L,NC]
    # PROFILES ADVANCED
    RewriteRule ^[a-z0-9_-]*-u([0-9]+)\.html$ /memberlist.php?mode=viewprofile&u=$1 [QSA,L,NC]
    # USER MESSAGES ADVANCED
    RewriteRule ^[a-z0-9_-]*-m([0-9]+)(-([0-9]+))?\.html$ /search.php?author_id=$1&sr=posts&start=$3 [QSA,L,NC]
    # GROUPS ADVANCED
    RewriteRule ^[a-z0-9_-]*-g([0-9]+)(-([0-9]+))?\.html$ /memberlist.php?mode=group&g=$1&start=$3 [QSA,L,NC]
    # POST
    RewriteRule ^post([0-9]+)\.html$ /viewtopic.php?p=$1 [QSA,L,NC]
    # THE TEAM
    RewriteRule ^the-team\.html$ /memberlist.php?mode=leaders [QSA,L,NC]
    # HERE IS A GOOD PLACE TO ADD OTHER PHPBB RELATED REWRITERULES

    # FORUM WITHOUT ID & DELIM
    # THESE FOUR LINES MUST BE LOCATED AT THE END OF YOUR HTACCESS TO WORK PROPERLY
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^[a-z0-9_-]+/?(page([0-9]+)\.html)?$ /viewforum.php?start=$2 [QSA,L,NC]
    # END PHPBB PAGES
    #####################################################
splitice
 
Posts: 4
Joined: Sat Mar 15, 2008 11:17 pm

Postby HB » Sat Mar 22, 2008 2:02 am

splitice wrote:sorry im not a good explainer when it comes to using terms.

Anyway heres the code of google-sitemap.php

Why not use GYM (Google Yahoo MSN sitemap generator) from phpBB-seo? Yes, I know V3 is not released yet, but it makes little sense to modify your code written in 2005 when dcz will be soon releasing a sitemap mod that directly supports URL remapping.
Dan Kehn
HB
phpBB SEO Team
phpBB SEO Team
 
Posts: 1019
Joined: Mon Oct 16, 2006 2:25 am

Postby splitice » Sat Mar 22, 2008 2:16 am

There is being one released. I didnt realise. How long is it expected to be? days, weeks, months
splitice
 
Posts: 4
Joined: Sat Mar 15, 2008 11:17 pm


Return to phpBB SEO MODS




Who is online

Users browsing this forum: No registered users and 3 guests