internal links opening in new window

Discussion forum for MOD Writers regarding MOD Development.
Locked
Piscator
Registered User
Posts: 120
Joined: Sat Mar 22, 2014 4:32 pm

internal links opening in new window

Post by Piscator »

Following on from this topic: viewtopic.php?f=46&t=2266976

Now an issue has came up with links posted in topics pointing to other topics.

links pasted as http://myforum.com are opening in new windows but links pasted as http://www.myforum.com are working as they should by opening on the same page. external links work fine by opening as a new browser window/tab.

how to auto detect both www and non-www internal links and open in same window :?:
Last edited by Oyabun1 on Thu May 28, 2015 9:14 pm, edited 1 time in total.
Reason: Moved from 3.0.x Support forum
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26514
Joined: Fri Aug 29, 2008 9:49 am

Re: internal links opening in new window

Post by Mick »

The address works fine using www, cookies etc. are good but not when you remove www. I can't speak for all hosts but mine has always redirected to the correct address irrespective of whether or not a www is typed, with no intervention from me. Maybe you should ask your host why yours doesn't do that.
  • "The more connected we get the more alone we become" - Kyle Broflovski©
  • "The good news is hell is just the product of a morbid human imagination.
    The bad news is, whatever humans can imagine, they can usually create.
    " - Harmony Cobel
Piscator
Registered User
Posts: 120
Joined: Sat Mar 22, 2014 4:32 pm

Re: internal links opening in new window

Post by Piscator »

Mick wrote:The address works fine using www, cookies etc. are good but not when you remove www. I can't speak for all hosts but mine has always redirected to the correct address irrespective of whether or not a www is typed, with no intervention from me. Maybe you should ask your host why yours doesn't do that.
Godaddy, Gofigure :roll:

Never had www issues on any other hosts, first time EVER coming across something like this. redirect works just need some sorta regex to deal with links.

ill post existing code that handles it in the morning. 2am just now so yeah, bed time.
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26514
Joined: Fri Aug 29, 2008 9:49 am

Re: internal links opening in new window

Post by Mick »

What did Godaddy say?
  • "The more connected we get the more alone we become" - Kyle Broflovski©
  • "The good news is hell is just the product of a morbid human imagination.
    The bad news is, whatever humans can imagine, they can usually create.
    " - Harmony Cobel
Piscator
Registered User
Posts: 120
Joined: Sat Mar 22, 2014 4:32 pm

Re: internal links opening in new window

Post by Piscator »

Mick wrote:What did Godaddy say?
It's not actually a godaddy issue for once.

its more to do with phpbb and how it parses its own links.

here is an example of links to this topic with and without www

viewtopic.php?f=46&t=2318366 <- recognised as internal link and made shorter

https://phpbb.com/community/viewtopic.p ... &t=2318366 < - not recognised as internal link

sorry but the reason the second link opens in a new window is because of code I added to viewtopic to open external links in a new window.

Code: Select all

    $message = str_replace('<a class="postlink" ', '<a class="postlink" onclick="window.open(this.href);return false;"', $message);
So the question is how to make phpbb recognise and format the link without www as internal, I just cant find which file handles this and adds "postlink-local" css class to the first url and makes it shorter.

while forum has been running a lot of members have been copying and pasting links to other topics from browser address bar so theres lots without www. doing a find and replace in the db is an option but id prefer a code solution to stop it possibly happening again.
Locked

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