Make topic accesible through f=x&t=x and not through t=x

Discussion forum for MOD Writers regarding MOD Development.
forforce
Registered User
Posts: 323
Joined: Fri Oct 04, 2013 7:57 am
Contact:

Make topic accesible through f=x&t=x and not through t=x

Post by forforce » Tue Nov 26, 2013 9:18 am

Hi, can you please tell me how can I make a topic , from example: http://www.cumseface.eu/viewtopic.php?f=34&t=84 to be accessed only with this url not not with url: http://www.cumseface.eu/viewtopic.php?t=84 . Now I can acces this post with both urls , I want to use the url only with: f=34&t=84 . Can this be done ? How ? Thanks in advance.
https://www.cumseface.eu , We have tutorials for everything / Te ajutam se te descurci singur .

forforce
Registered User
Posts: 323
Joined: Fri Oct 04, 2013 7:57 am
Contact:

Re: Make topic accesible through f=x&t=x and not through t=x

Post by forforce » Tue Nov 26, 2013 11:12 pm

Nobody? :(
https://www.cumseface.eu , We have tutorials for everything / Te ajutam se te descurci singur .

User avatar
Lumpy Burgertushie
Registered User
Posts: 66469
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Make topic accesible through f=x&t=x and not through t=x

Post by Lumpy Burgertushie » Tue Nov 26, 2013 11:20 pm

sorry but what you ask doesn't really make any sense.

what is the purpose in this?

what do you want the final outcome to be.,

not how you think it should be accomplished.


robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

If a tree falls in the forest and nobody is there, does it make a sound?

User avatar
imkingdavid
Former Team Member
Posts: 2667
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: Make topic accesible through f=x&t=x and not through t=x

Post by imkingdavid » Wed Nov 27, 2013 6:12 pm

You can just add a condition in viewtopic.php to show an error if a forum ID (the f=X parameter) was not specified. What, if I may ask, is the goal of this? By doing this you are potentially breaking links that people may already have bookmarked and I'm not sure, but there may be places in the software where the links to topics are generated with only the topic ID and not the forum ID, in which case those links would no longer work either.
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

forforce
Registered User
Posts: 323
Joined: Fri Oct 04, 2013 7:57 am
Contact:

Re: Make topic accesible through f=x&t=x and not through t=x

Post by forforce » Wed Nov 27, 2013 11:04 pm

Hi, the goal of doing this is for my facebook and google+ like buttons, I would like to have only one url to acces a topic but I have allot ot them , duplicates and google is indexing them some with an url, some with other url and so on. If aa topic is indexed on google with url with only t=x and I share the url for the same topic to people with f=x&t=x , on one url I would have x number of likes, on other url I would have y number of likes and so one for each url that indicates the same topic. Can this be solved? How can I make those many urls for the same topic to become just a single url to acces the same topic? How can I remove duplicate urls? Not to make them more human readable or seo but to help me with this problem for example. I don't want different number of likes for the same topic and I don't want google to index my urls as it wishes, only in one format. Thank you.
Edit: adding this lines to robots.txt can help with google index?
Disallow: /viewtopic.php?p=
Disallow: /viewtopic.php?=&p=
Disallow: /viewtopic.php?t=
Disallow: /viewtopic.php?start=
Disallow: /*&view=previous
Disallow: /*&view=next
Disallow: /*&sid=
Disallow: /*&p=
Disallow: /*&sd=a
Disallow: /*&start=0
https://www.cumseface.eu , We have tutorials for everything / Te ajutam se te descurci singur .

Peter77sx
Registered User
Posts: 3253
Joined: Wed Nov 09, 2005 2:51 pm

Re: Make topic accesible through f=x&t=x and not through t=x

Post by Peter77sx » Thu Nov 28, 2013 12:25 am

You would want canonical URL mod for that you can probably search for it on this site somewhere. It might be in mod database by now.

forforce
Registered User
Posts: 323
Joined: Fri Oct 04, 2013 7:57 am
Contact:

Re: Make topic accesible through f=x&t=x and not through t=x

Post by forforce » Thu Nov 28, 2013 4:14 pm

Interesting, I installed allready canonical url mod but how do I know if it's working or not? Hmmm. I'm using phpbb v 3.0.12
https://www.cumseface.eu , We have tutorials for everything / Te ajutam se te descurci singur .

forforce
Registered User
Posts: 323
Joined: Fri Oct 04, 2013 7:57 am
Contact:

Re: Make topic accesible through f=x&t=x and not through t=x

Post by forforce » Thu Nov 28, 2013 10:56 pm

Please somebody help me with this problem , I can`t fix it :( .
https://www.cumseface.eu , We have tutorials for everything / Te ajutam se te descurci singur .

User avatar
ViolaF
Registered User
Posts: 1452
Joined: Tue Aug 14, 2012 11:52 pm

Re: Make topic accesible through f=x&t=x and not through t=x

Post by ViolaF » Fri Nov 29, 2013 8:40 pm

open

viewtopic.php

find

Code: Select all

$post_id    = request_var('p', 0); 
after add

Code: Select all

//adding f= param if not present for viewtopic / ViolaF
if ($topic_id && !$forum_id){
$sql = 'SELECT forum_id
        FROM ' . TOPICS_TABLE . "
        WHERE topic_id = $topic_id";
$result = $db->sql_query($sql);
$forum_it = (int) $db->sql_fetchfield('forum_id');
$db->sql_freeresult($result);
$view_topic_url_params = 'f=' . $forum_it . '&t=' . $topic_id;
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);
header("Location:" .$view_topic_url);}
//adding f= param if not present for viewtopic / ViolaF   
Thats it.

Whenever the f= param is missing in viewtopic url, it will be added.

This Code is tested and adds one additional sql query to viewtopic.php

User avatar
ViolaF
Registered User
Posts: 1452
Joined: Tue Aug 14, 2012 11:52 pm

Re: Make topic accesible through f=x&t=x and not through t=x

Post by ViolaF » Fri Nov 29, 2013 8:45 pm

imkingdavid wrote:By doing this you are potentially breaking links that people may already have bookmarked
This issue is not given with my solution. All old links will work :D
Also p= param links without f= param are working as intended :geek:

forforce
Registered User
Posts: 323
Joined: Fri Oct 04, 2013 7:57 am
Contact:

Re: Make topic accesible through f=x&t=x and not through t=x

Post by forforce » Fri Nov 29, 2013 9:23 pm

You are a genious, this is working as it should , thank you very much! . Now I have an idea , can`t we use this type of code to remove duplicate urls ? To add or remove parameters from url so if we acces any duplicate url, to be redirected to a single type one ? :) .
p.s. Can`t we use a similar code to remove f parameter from url ? So we can have only t parameter when accesing a topic ? This way we won`t have problems with google index if we will move a topic to another forum ;).
https://www.cumseface.eu , We have tutorials for everything / Te ajutam se te descurci singur .

User avatar
ViolaF
Registered User
Posts: 1452
Joined: Tue Aug 14, 2012 11:52 pm

Re: Make topic accesible through f=x&t=x and not through t=x

Post by ViolaF » Fri Nov 29, 2013 9:32 pm

of course. near all is possible. so, bcs. is see your ideas jumping, please be repeat a concret wish ;)

User avatar
ViolaF
Registered User
Posts: 1452
Joined: Tue Aug 14, 2012 11:52 pm

Re: Make topic accesible through f=x&t=x and not through t=x

Post by ViolaF » Fri Nov 29, 2013 9:34 pm

to which "dream link" the code should go

User avatar
ViolaF
Registered User
Posts: 1452
Joined: Tue Aug 14, 2012 11:52 pm

Re: Make topic accesible through f=x&t=x and not through t=x

Post by ViolaF » Fri Nov 29, 2013 9:35 pm

and in which cases

forforce
Registered User
Posts: 323
Joined: Fri Oct 04, 2013 7:57 am
Contact:

Re: Make topic accesible through f=x&t=x and not through t=x

Post by forforce » Fri Nov 29, 2013 9:41 pm

ok, instead of: f=x&t=x or t=x&p=x , url to go only to : t=x . Can this be done ? Thanks in advance.
https://www.cumseface.eu , We have tutorials for everything / Te ajutam se te descurci singur .

Locked

Return to “[3.0.x] MOD Writers Discussion”