What happens to browser url after clicking next topic link

Discussions and support about the different URL Rewriting techniques for phpBB.

Moderator: Moderators

What happens to browser url after clicking next topic link

Postby tlgcmn » Thu Feb 18, 2010 1:51 pm

I have been trying to rewrite the next-previous topic link URLs since last week. But i can't understand where and how the browser url changes after clicking next-previous topic button? :?

Here is an example. Normally, without rewrite, when you are in forum1-topic2, the browser url is like this:
Code: Select all
http://localhost/phpbb/viewtopic.php?f=1&t=2

When you are viewing topic2, the previous topic link url is this:
Code: Select all
http://localhost/phpbb/viewtopic.php?f=1&t=2&view=previous

If you click previous, forum1-topic1 is opened but the browser url is:
Code: Select all
http://localhost/phpbb/viewtopic.php?f=1&t=2&view=previous

is not:
Code: Select all
http://localhost/phpbb/viewtopic.php?f=1&t=1

Here is my question:
I am using mod rewrite in advanced mode. So when i am in forum1-topic2, its browser url is like this:
Code: Select all
http://localhost/phpbb/games/velvet-assasin-t2.html

The previous and also next topic link URLs aren't rewritten. I am trying to rewrite these URLs and get rid of "?" and "&".
So the previous topic link url is again:
Code: Select all
http://localhost/phpbb/viewtopic.php?f=1&t=2&view=previous

When i click previous topic, it opens forum1-topic1 as it should be but if there is a previous topic to be displayed, the browser url changes to:
Code: Select all
http://localhost/phpbb/games/fifa-2010-t1.html

I am trying to find how does this happen? Is this change made in viewtopic.php or phpbb_seo_class.php or somewhere else? Is it a redirect or sth. different? If someone tells me where and how these changes occur, i will be very pleased :) Because when there is a previous or next topic, the browser url changes and $_REQUEST['view'] returns empty. I can't get from the url if previous or next topic button is clicked or not. After rewriting URL, i will try to get it from the browser URL by $_SERVER['REQUEST_URI'] and parse it if it has view or not.
(P.S : I think, previous-next topic buttons are only in subsilver2 based styles. So if you are using prosilver, don't try to find these buttons :) )
tlgcmn
 
Posts: 19
Joined: Wed Jan 27, 2010 3:07 pm

Advertisement

Re: What happens to browser url after clicking next topic link

Postby tlgcmn » Sat Feb 20, 2010 11:52 am

Finally i have figured out what happens. When zero duplicate mode is open, the seo_chk_dupe() function that is called from viewtopic.php redirects the url
Code: Select all
http://localhost/phpbb/viewtopic.php?f=1&t=2&view=previous
to
Code: Select all
http://localhost/phpbb/games/fifa-2010-t1.html
if there is previous topic.

After making some self coding, now, my previos-next topic link URLs are showing previously rewritten previous-next topic URLs. So my new previous topic link URL is
Code: Select all
http://localhost/phpbb/games/fifa-2010-t1.html
if i am in topic2. When i am in topic1, the next topic link URL becomes
Code: Select all
http://localhost/phpbb/games/velvet-assasin-t2.html
. If there isn't previous or next topic, the button isn't displayed. If anybody is searching sth. like that, pm me and i will send what changes i have done.
tlgcmn
 
Posts: 19
Joined: Wed Jan 27, 2010 3:07 pm

Re: What happens to browser url after clicking next topic li

Postby dcz » Fri Mar 12, 2010 1:14 pm

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

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Re: What happens to browser url after clicking next topic li

Postby prabhuganapathy » Wed Oct 13, 2010 12:50 pm

tlgcmn wrote:Finally i have figured out what happens. When zero duplicate mode is open, the seo_chk_dupe() function that is called from viewtopic.php redirects the url
Code: Select all
http://localhost/phpbb/viewtopic.php?f=1&t=2&view=previous
to
Code: Select all
http://localhost/phpbb/games/fifa-2010-t1.html
if there is previous topic.

After making some self coding, now, my previos-next topic link URLs are showing previously rewritten previous-next topic URLs. So my new previous topic link URL is
Code: Select all
http://localhost/phpbb/games/fifa-2010-t1.html
if i am in topic2. When i am in topic1, the next topic link URL becomes
Code: Select all
http://localhost/phpbb/games/velvet-assasin-t2.html
. If there isn't previous or next topic, the button isn't displayed. If anybody is searching sth. like that, pm me and i will send what changes i have done.


HI tlgcmn,

i faced same problem, please give me the code change details

Thanks,
prabhu
prabhuganapathy
 
Posts: 7
Joined: Wed Oct 13, 2010 12:37 pm
Location: chennai

Re: What happens to browser url after clicking next topic li

Postby tlgcmn » Wed Oct 13, 2010 3:03 pm

Isn't it fixed in the last version of phpbb?
tlgcmn
 
Posts: 19
Joined: Wed Jan 27, 2010 3:07 pm

Re: What happens to browser url after clicking next topic li

Postby prabhuganapathy » Wed Oct 13, 2010 3:15 pm

tlgcmn wrote:Isn't it fixed in the last version of phpbb?

hi
am using phpbb3.0.6 version, iam using phpbb-SEO, but previous and next topic link URLs aren't rewritten. i need to do. please help me?
prabhuganapathy
 
Posts: 7
Joined: Wed Oct 13, 2010 12:37 pm
Location: chennai

Re: What happens to browser url after clicking next topic li

Postby tlgcmn » Wed Oct 13, 2010 3:17 pm

Ok, if i could remember the changes that i had made, i will send them to you. I'm working on it now.
tlgcmn
 
Posts: 19
Joined: Wed Jan 27, 2010 3:07 pm

Re: What happens to browser url after clicking next topic li

Postby prabhuganapathy » Wed Oct 13, 2010 3:37 pm

tlgcmn wrote:Ok, if i could remember the changes that i had made, i will send them to you. I'm working on it now.

Ok. thanks for your help. am waiting for your help.
prabhuganapathy
 
Posts: 7
Joined: Wed Oct 13, 2010 12:37 pm
Location: chennai

Re: What happens to browser url after clicking next topic li

Postby tlgcmn » Wed Oct 13, 2010 3:48 pm

Do you have the function "function get_prev_next_topic($topic_id, $view = 'next')" in your php_seo_class_php file?
tlgcmn
 
Posts: 19
Joined: Wed Jan 27, 2010 3:07 pm

Re: What happens to browser url after clicking next topic li

Postby prabhuganapathy » Thu Oct 14, 2010 4:05 am

no i haven't that function in my php_seo_class_php file .
prabhuganapathy
 
Posts: 7
Joined: Wed Oct 13, 2010 12:37 pm
Location: chennai

Re: What happens to browser url after clicking next topic li

Postby prabhuganapathy » Thu Oct 14, 2010 4:08 pm

how can i resolved that issue. please give me the advice.

Thanks.
prabhuganapathy
 
Posts: 7
Joined: Wed Oct 13, 2010 12:37 pm
Location: chennai

Re: What happens to browser url after clicking next topic li

Postby tlgcmn » Thu Oct 14, 2010 8:02 pm

in phpbb_seo_class.php file:

FIND
Code: Select all
} // End of the phpbb_seo class

ADD BEFORE
Code: Select all
   function get_prev_next_topic($topic_id, $view = 'next'){
      $sql_condition = ($view == 'next') ? '>' : '<';
      $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC';
      global $user, $db, $config, $cache, $auth;
      global $HTTP_COOKIE_VARS, $HTTP_GET_VARS;

      $sql = 'SELECT forum_id, topic_last_post_time
            FROM ' . TOPICS_TABLE . '
            WHERE topic_id = ' . $topic_id;
         $result = $db->sql_query($sql);
         $row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);
      
      if (!$row)
      {
         return null;
         /*$user->setup('viewtopic');
         // OK, the topic doesn't exist. This error message is not helpful, but technically correct.
            trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');*/
      }
      else
      {
         $sql = 'SELECT topic_id, forum_id, topic_title, topic_url
               FROM ' . TOPICS_TABLE . '
               WHERE forum_id = ' . $row['forum_id'] . "
                  AND topic_moved_id = 0
                  AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
                  " . (($auth->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . "
               ORDER BY topic_last_post_time $sql_ordering";
            $result = $db->sql_query_limit($sql, 1);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            
         if (!$row)
         {
            return null;
            /*$user->setup('viewtopic');
               trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');*/
         }
         else
         {
            $topic_id = $row['topic_id'];            
            // Check for global announcement correctness?
            if (!$row['forum_id'] && !$forum_id)
            {
               return null;/*trigger_error('NO_TOPIC');*/
            }
            else if ($row['forum_id'])
            {
               //$forum_id = $row['forum_id'];
               $url = $row['topic_url']. $topic_id. $this->seo_ext['topic'];
               return $url;
            }
         }
      }
   }

in viewtopic.php file
FIND
Code: Select all
$hilit_words   = request_var('hilit', '', true);

ADD AFTER
Code: Select all
$next_url = $phpbb_seo->get_prev_next_topic($topic_id,'next');
$prev_url = $phpbb_seo->get_prev_next_topic($topic_id,'previous');

FIND
Code: Select all
   'U_VIEW_OLDER_TOPIC'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=previous"),
   'U_VIEW_NEWER_TOPIC'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=next"),

REPLACE WITH
Code: Select all
   'U_VIEW_OLDER_TOPIC'   => empty($prev_url) ? '' : $prev_url,
   'U_VIEW_NEWER_TOPIC'   => empty($next_url) ? '' : $next_url,

I think that they were all the changes that i had made. If there will be any problem, you can write there. I haven't had any problem for 7 months with these changes but maybe there could be sth. missing that i hadn't seen.

I don't have SELECT buttons in my Code tags. I think they don't exist in subsilver2 type styles. Does anybody has any idea how can i add SELECT buttons to Code tags which are used in posts?
tlgcmn
 
Posts: 19
Joined: Wed Jan 27, 2010 3:07 pm

Re: What happens to browser url after clicking next topic li

Postby SeO » Thu Oct 14, 2010 9:18 pm

From what I understand, with your code, you will get for let's says a topic with url my-topic-txx.html, next and previous links of this form :
topic with url my-topic-txx.html?view=next
topic with url my-topic-txx.html?view=previous

With same title and ID. Or worst, (well, actually a bit better since this could mean we avoid the dupe, but loose the actual previous / next feature) just the same url as the current topic viewed.

Problem is, these are duplicate of the two actual previous and next topic urls (the one you would get if you'd visit them directly form the forum list), and worst, not that easy to deal with, unless of course you also use the zero duplicate, but still, there is no real point to spend so much effort to output duplicated urls.

And this is the actual reason why these two are left unrewritten, because we though we'd better spend no resources to still output a duplicate. So we choose to maintain the original form for these so that they are fully ignored by bots following the robots.txt exclusions (which also lowers the load on the server compared to repeated http301 redirections). The alternative would be to add at least one SQL if not two on each topic page view and I really don't think it would be worth it for such links.

So t's all on purpose, and can be circumvented with no SQL, have a look at the filter array in phpbb_seo/phpbb_seo_class.php :
Code: Select all
   var   $seo_stop_vars = array('view=', 'mark=', 'watch=', 'hash=');


Removing the 'view=' entry will lead to the same result as your code. But remember, more is not always better, SEO should not be where you spend the most resources IMHO, content and user experience should ;)
SeO
Admin
Admin
 
Posts: 6333
Joined: Wed Mar 15, 2006 9:41 pm

Re: What happens to browser url after clicking next topic li

Postby prabhuganapathy » Tue Oct 19, 2010 11:06 am

tlgcmn wrote:in phpbb_seo_class.php file:

FIND
Code: Select all
} // End of the phpbb_seo class

ADD BEFORE
Code: Select all
   function get_prev_next_topic($topic_id, $view = 'next'){
      $sql_condition = ($view == 'next') ? '>' : '<';
      $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC';
      global $user, $db, $config, $cache, $auth;
      global $HTTP_COOKIE_VARS, $HTTP_GET_VARS;

      $sql = 'SELECT forum_id, topic_last_post_time
            FROM ' . TOPICS_TABLE . '
            WHERE topic_id = ' . $topic_id;
         $result = $db->sql_query($sql);
         $row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);
      
      if (!$row)
      {
         return null;
         /*$user->setup('viewtopic');
         // OK, the topic doesn't exist. This error message is not helpful, but technically correct.
            trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');*/
      }
      else
      {
         $sql = 'SELECT topic_id, forum_id, topic_title, topic_url
               FROM ' . TOPICS_TABLE . '
               WHERE forum_id = ' . $row['forum_id'] . "
                  AND topic_moved_id = 0
                  AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
                  " . (($auth->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . "
               ORDER BY topic_last_post_time $sql_ordering";
            $result = $db->sql_query_limit($sql, 1);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            
         if (!$row)
         {
            return null;
            /*$user->setup('viewtopic');
               trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');*/
         }
         else
         {
            $topic_id = $row['topic_id'];            
            // Check for global announcement correctness?
            if (!$row['forum_id'] && !$forum_id)
            {
               return null;/*trigger_error('NO_TOPIC');*/
            }
            else if ($row['forum_id'])
            {
               //$forum_id = $row['forum_id'];
               $url = $row['topic_url']. $topic_id. $this->seo_ext['topic'];
               return $url;
            }
         }
      }
   }

in viewtopic.php file
FIND
Code: Select all
$hilit_words   = request_var('hilit', '', true);

ADD AFTER
Code: Select all
$next_url = $phpbb_seo->get_prev_next_topic($topic_id,'next');
$prev_url = $phpbb_seo->get_prev_next_topic($topic_id,'previous');

FIND
Code: Select all
   'U_VIEW_OLDER_TOPIC'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=previous"),
   'U_VIEW_NEWER_TOPIC'   => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=next"),

REPLACE WITH
Code: Select all
   'U_VIEW_OLDER_TOPIC'   => empty($prev_url) ? '' : $prev_url,
   'U_VIEW_NEWER_TOPIC'   => empty($next_url) ? '' : $next_url,

I think that they were all the changes that i had made. If there will be any problem, you can write there. I haven't had any problem for 7 months with these changes but maybe there could be sth. missing that i hadn't seen.

I don't have SELECT buttons in my Code tags. I think they don't exist in subsilver2 type styles. Does anybody has any idea how can i add SELECT buttons to Code tags which are used in posts?

Thanks tlgcmn. but its throwing an error . am investigating that issue......
prabhuganapathy
 
Posts: 7
Joined: Wed Oct 13, 2010 12:37 pm
Location: chennai


Return to phpBB mod Rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 3 guests