Open links in new tab

Discussion of non-phpBB related topics with other phpBB.com users.
Forum rules
General Discussion is a bonus forum for discussion of non-phpBB related topics with other phpBB.com users. All site rules apply.
User avatar
AmigoJack
Registered User
Posts: 6108
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Open links in new tab

Post by AmigoJack »

Again I want to outline: don't force all your board users what only you want. Why not setting up your local software to always open new tabs?
AmigoJack wrote: Tue Jun 25, 2019 6:34 amIt also comes down to the internet browser and how it lets you make settings per website - years ago Opera (v12 and before) could be configured perfectly for all that without being bound to what the website owner wanted or missed.
...
Up to this day I don't understand website owners that force me to do at least 5 clicks (and then I the actual data is still hidden in a PDF) with the outcome of having 5 new tabs - as if I'm never done reading any of the previous pages.
User avatar
globetrotting
Registered User
Posts: 217
Joined: Thu Jan 15, 2004 8:14 pm
Location: globetrotting
Contact:

Re: Open links in new tab

Post by globetrotting »

warmweer wrote: Tue Dec 17, 2019 9:39 pmActually, the elonw is quite transparent and you could edit it to cancel the check for internal inks (which are left as they are), so that all links are treated as "external" and open in a new window...
Ty! I will definitely have a closer look at that asap (but still working on more essential adaptations).
I also found that: https://www.phpbb.com/support/docs/en/3 ... w-windows/
User avatar
globetrotting
Registered User
Posts: 217
Joined: Thu Jan 15, 2004 8:14 pm
Location: globetrotting
Contact:

Re: Open links in new tab

Post by globetrotting »

warmweer wrote: Tue Dec 17, 2019 9:39 pmActually, the elonw is quite transparent and you could edit it to cancel the check for internal inks...
My wish is foremost to have selectively the search result page of phpBB-search opened in a new tab as it would ease my workflow considerably. (I couldn't add this condition to elonw myself.)
For that reason I opened a new theme here: viewtopic.php?f=641&t=2538581
User avatar
WDUK
Registered User
Posts: 63
Joined: Fri Jun 04, 2021 3:24 pm
Location: England
Contact:

Re: Open links in new tab

Post by WDUK »

Hi,

Did anyone come up with a solution for this? I have read as many threads on this topic as I can face now.

I am competent at English grammar and use of my computer mouse, so do not currently require help with that ;)

I am also aware of the pros and cons of opening links in new tabs.

Having decided that the best option for me is to have the 'Forum Rules' link open in a new tab, because the rules are on a WordPress part of my site, I am still struggling to find some BBCode that could do this.

I tried the options here https://www.theadminzone.com/threads/ad ... dow.98659/ but with no luck.

Any help will be most appreciated :-)
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26502
Joined: Fri Aug 29, 2008 9:49 am

Re: Open links in new tab

Post by Mick »

@WDUK: This will open in a new window if that’s any good? https://www.phpbb.com/customise/db/exte ... ew_window/

Edit: Can do tabs too https://www.phpbb.com/customise/db/exte ... pic/209016
  • "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
User avatar
warmweer
Jr. Extension Validator
Posts: 11234
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Bel ... gium
Contact:

Re: Open links in new tab

Post by warmweer »

WDUK wrote: Tue May 03, 2022 3:28 pm Did anyone come up with a solution for this? I have read as many threads on this topic as I can face now.
Created a new BBcode on a test board just now (and it works)

BBcode: [nwurl={URL}]{TEXT}[/nwurl]
HTML: <a href="{URL}" target="_blank">{TEXT}</a>
Help: [nwurl=www.url.com]this is your text[nwurl]

This (for me) opens the link in a new tab (not a new browser window)


However, your request seems to be specific to forum rules and this won't work with forum rules in Manage Forums > Edit forum > Forum rules:
If all you want to do is to post a link to an external rules page: it should work.
User avatar
WDUK
Registered User
Posts: 63
Joined: Fri Jun 04, 2021 3:24 pm
Location: England
Contact:

Re: Open links in new tab

Post by WDUK »

Thank you both, I now realise I didn't explain clearly what I wanted to achieve.

I did want this to work in the Edit Forum > Forum Rules > Forum rules: "Forum rules are displayed at any page within the given forum." field. But it seems I cannot do do that.

If I put a link in the 'Link to Forum Rules' field I cannot add the "please read the rules..." text I want to add, as both do not appear to show up on the frontend.

I'm thinking perhaps a sticky post? Unless I can have some sort of permanent, global announcement that the code @warmweer provided could work in?

Also in users' signatures, we intend to link them back to parts of the WordPress site. Might this work with the code @warmweer provided?

Or perhaps I may need to use the extension mentioned by @Mick? :)
User avatar
warmweer
Jr. Extension Validator
Posts: 11234
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Bel ... gium
Contact:

Re: Open links in new tab

Post by warmweer »

WDUK wrote: Tue May 03, 2022 6:12 pmI'm thinking perhaps a sticky post? Unless I can have some sort of permanent, global announcement that the code @warmweer provided could work in?
There's an extension (Board Announcements) which is probably just what you need.
I see it hasn't been validated for phpBB3.3 but I have used it on 3.3.x
WDUK wrote: Tue May 03, 2022 6:12 pmAlso in users' signatures, we intend to link them back to parts of the WordPress site. Might this work with the code @warmweer provided?
BBcode can be used in signatures, so it's perfectly possible to have links in signatures open in a new tab or window.
WDUK wrote: Tue May 03, 2022 6:12 pmOr perhaps I may need to use the extension mentioned by @Mick? :)
Make a copy of your board on personal webserver (your PC) and use that to try various extensions which seem interesting, and at no risk whatsoever to your live board.

As to the forum rules: those are specific to the forum they're assigned to.
If you have only 1 category, then those category rules would be visible throughout your whole board (well, not the ACP, MCP and UCP)
User avatar
WDUK
Registered User
Posts: 63
Joined: Fri Jun 04, 2021 3:24 pm
Location: England
Contact:

Re: Open links in new tab

Post by WDUK »

I have added the Board Announcements extension and that seems to do what we need. I have linked the rules to a post on here. Within that post I can link out to the WordPress website for those that want to read every detail. As in nobody :D

I'll try the external link code in the user signatures too.

This forum is in construction still so I am doing all my experimenting first thankfully. We have a set number of forums with specific sub forums. We may alter things in the future of course.

Thank you again for your fast help :)
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Open links in new tab

Post by axe70 »

i did not read all nice and surely beautiful answers here below. Nor if it is a question that should get an answer to resolve an issue or just a comment to a forum's behavior when external links clicked.

Anyway let me add mine stupid obvious, may also out of the contest because it was not the question.

Open external (i think the question is about external links that points to a resource out of the phpBB)
links in a new tab.... an extension? yes can be injected via an extension, but maybe it is easier also like this

into overall_footer.html, since passed url that are external, do not contains domain name (but there are more ways to detect and get the right result):

Code: Select all

<script>
var boardU = "{BOARD_URL}";
$(document).on("click", "a", function(e) {
  var href = $(this).attr("href"); // this line required and was missed
// external link?
if ((this.href.indexOf(boardU) > -1) != true){
 if(/^(f|ht)tps?:\/\//i.test(href))
 {
  e.preventDefault();
  window.open(href,'_blank');
  return;
 }
}
});
</script>
and do not forget to stay cool! ...which may is another not useful consideration ;)

[JS code EDITED]
User avatar
warmweer
Jr. Extension Validator
Posts: 11234
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Bel ... gium
Contact:

Re: Open links in new tab

Post by warmweer »

axe70 wrote: Sun May 08, 2022 8:28 am ...
Open external (i think the question is about external links that points to a resource out of the phpBB)
links in a new tab.... an extension? yes can be injected via an extension, but maybe it is easier also like this
...
And the downside is that all external links will be opened in a new tab (+ it's avoidable custom coding).
User avatar
axe70
Registered User
Posts: 752
Joined: Sun Nov 17, 2002 10:55 am
Location: Italy
Name: Alessio
Contact:

Re: Open links in new tab

Post by axe70 »

I assumed that the needed result was this.

About the custom avoidable code, it a point of view that to achieve a simple result like this, you have to write or edit an existing extension that inject these few lines. So easy to do and convenient when theme update. Anyway i found it easy to apply my custom code and copy and move when necessary, but it is my case, i update the theme rarely. Cheers

The world is beautiful because various.
User avatar
WDUK
Registered User
Posts: 63
Joined: Fri Jun 04, 2021 3:24 pm
Location: England
Contact:

Re: Open links in new tab

Post by WDUK »

Hi again all,

I lost my phpBB database in a server move, so starting again.

I added the forum rules link to the Board Announcements extension as before.

But whatever I try, including code suggested above, I cannot remember how to get the link to open in a new tab. The rules are on the main WordPress website.

Any help will be appreciated :-)

https://farmgear.co.uk/farming-forum/in ... 95b73efe5c
User avatar
ssl
Registered User
Posts: 1606
Joined: Sat Feb 08, 2020 2:15 pm
Location: Le Lude, Pays de la Loire - France
Name: Fred Rimbert
Contact:

Re: Open links in new tab

Post by ssl »

Use the link contain in this post: viewtopic.php?p=15275016#p15275016
User avatar
warmweer
Jr. Extension Validator
Posts: 11234
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Bel ... gium
Contact:

Re: Open links in new tab

Post by warmweer »

WDUK wrote: Tue Mar 07, 2023 5:54 pm I lost my phpBB database in a server move, so starting again.
...
You do have a copy of that database stored safely somewhere, don't you?
Even if it not the most recent backup, it'll certainly contain more that a new database.
Post Reply

Return to “General Discussion”