Forum URL's should not open in a new window

Started by Mr. Jinx, January 07, 2005, 11:35:31 AM

Previous topic - Next topic

Mr. Jinx

This is a feature request, but maybe it should be a mod I don't know.

If you post a link to another thread in you message, the new thread will open in a new window.
This is ok if you put a link to antoher site, but own form links should open in the same window.

It would be cool if SMF checks the URL. If it starts with your board URL (http://www.simplemachines.org/community) then it shouldn't open in a new window!

Cccddd


Peter Duggan

Quote from: Mr. Jinx on January 07, 2005, 11:35:31 AM
This is a feature request, but maybe it should be a mod I don't know.

IMHO, an admin setting for this would be good. IOW, I'd use it! :)

Cccddd

an admin setting is what I was talking about, but bleh im too tired right now to focus on the code.

what someone (maybe me later) is add a features/options config variable, that is checked for in Subs.php near line 890 where it starts parsing the links. Basically, around this:

target="_blank"

make it look like this:

' . ($TheSettingsArrayName['settingName'] ? 'target="_top"' : 'target="_blank"') . '

Cccddd

I used _top just in case the site uses frames. not likely, but its always ugly to have frames repeat.

Mr. Jinx

Hmm.. this will open all links on the same page if I'm correct.
It would be nicer if only the links that point to your own site open in the current browser. If it's an external link it should open in a new window.

_complex


Peter Duggan

Quote from: Mr. Jinx on January 07, 2005, 02:46:27 PM
If it's an external link it should open in a new window.

Hmmm... could be a good opportunity to provide the choice for everything...

* Peter Duggan still contends that target="_blank" as overused! :P

Wounded Knee

[url]http://www.simplemachines.org/community/index.php?board=3.0[/url] 
http://www.simplemachines.org/community/index.php?board=3.0 
 
[iurl]http://www.simplemachines.org/community/index.php?board=3.0[/iurl]   
http://www.simplemachines.org/community/index.php?board=3.0

Peter Duggan

Quote from: Wounded Knee on January 07, 2005, 07:00:52 PM
[url]http://www.simplemachines.org/community/index.php?board=3.0[/url] 
http://www.simplemachines.org/community/index.php?board=3.0 
 
[iurl]http://www.simplemachines.org/community/index.php?board=3.0[/iurl]   
http://www.simplemachines.org/community/index.php?board=3.0

But that's not the point! ::)

Mr. Jinx

Quote from: Peter Duggan on January 07, 2005, 06:48:54 PM
Quote from: Mr. Jinx on January 07, 2005, 02:46:27 PM
If it's an external link it should open in a new window.

Hmmm... could be a good opportunity to provide the choice for everything...


I don't think the user should control this. As a webmaster I want that all internal links open in the current window, and all links that point to other sites open in a new window.
I'll try making something myself. This shouldn't be that hard..

mytreo

Quote from: Mr. Jinx on January 08, 2005, 07:12:24 AM
I don't think the user should control this. As a webmaster I want that all internal links open in the current window, and all links that point to other sites open in a new window.
Fully agree.

Quote
I'll try making something myself. This shouldn't be that hard..

Please let us know how you get on :)
Treo forum - Powered by SMF, of course
Treo news - powered by MovableType and integrated with SMF
Treo downloads - hacked from phpNuke and integrated with SMF
Treo knowledge base - powered by Wikka and integrated with SMF
Treo 650 | Treo 700w | Treo 700p

Tesseract

This could/should even be a choice by the users...

I know I like that all links, even internal, open in new windows...

/Tesseract

Mr. Jinx

In subs.php replace:


// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
'~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie' => isset($disabled['url']) ? 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'' : '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'&#64;\'))) . \'</a>\'',
'~\[url=(.+?)\](.+?)\[/url\]~ie' => isset($disabled['url']) ? '\'$2 ($1)\'' : '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'&#64;\')) . \'</a>\'',
'~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i' => isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>',


with:


// Find a (named?) URL... [url]www.simplemachines.org[/url] or [url=www.simplemachines.org]SMF[/url]
'~\[url=([^\]]+?)\]([^\]]*?\[url(?:=[^\]]+?)?\].+?\[/url\].*?)\[/url\]~ie' => isset($disabled['url']) ? 'preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', \'$2\') . \' ($1)\'' : '\'<a href="$1" target="_blank">\' . preg_replace(\'~(\[url.*?\]|\[/url\])~\', \'\', strtr(\'$2\', array(\'@\' => \'&#64;\'))) . \'</a>\'',
'~\[url=http://www.simplemachines.org/community/(.+?)\](.+?)\[/url\]~ie' => isset($disabled['url']) ? '\'$2 ($1)\'' : '\'<a href="http://www.simplemachines.org/community/$1" target="_top">\' . strtr(\'$2\', array(\'@\' => \'&#64;\')) . \'</a>\'',
'~\[url=(.+?)\](.+?)\[/url\]~ie' => isset($disabled['url']) ? '\'$2 ($1)\'' : '\'<a href="$1" target="_blank">\' . strtr(\'$2\', array(\'@\' => \'&#64;\')) . \'</a>\'',
'~\[url\]http://www.simplemachines.org/community/(?:<br />)*(.+?)(?:<br />)*\[/url\]~i' => isset($disabled['url']) ? '$1' : '<a href="http://www.simplemachines.org/community/$1" target="_top">http://www.simplemachines.org/community/$1</a>',
'~\[url\](?:<br />)*(.+?)(?:<br />)*\[/url\]~i' => isset($disabled['url']) ? '$1' : '<a href="$1" target="_blank">$1</a>',


Don't forget to replace "http://www.simplemachines.org/community/" with your forum url.
In fact this should be the variable "$boardurl" but I couldn't get that to work. I'm also not sure about the first line. It's unreadable for me :(

Cccddd

you gotta add $boardurl to the "global" line a few lines above where you are talking about.

and yeah what i posted above would do it for all sites. I was so tired i forgot to say above all the url parsing, you have to write an if statement, that says if the admin setting is true, and the url is the local site, THEN set whatever variable to 1, and if that is set to 1 in the url parsing, then it replaces _blank with _top.

I was so tired I forgot more when i was sober than when i was drunk!

Cccddd

and im in germany if you are wondering why I said "last night" when it was daytime for all y'all :)

Peter Duggan

Quote from: mytreo on January 08, 2005, 08:11:36 AM
Quote from: Mr. Jinx on January 08, 2005, 07:12:24 AM
I don't think the user should control this. As a webmaster I want that all internal links open in the current window, and all links that point to other sites open in a new window.
Fully agree.

1. When I suggested 'the choice for everything', I was thinking of an admin option to apply this to either site links or all links as well as a user profile option.
2. Since the user already has the choice to right-click links to open them in a new window or copy/drag them to open them in the same window, he/she technically already has this control.
3. Since your forum is dynamic and it's not hurting you for the pages your users see to accommodate their preferences, you've nothing to lose. So, assuming the idea of the new windows for external sites is to keep the users at yours, you should rest assured that if it's interesting to them they'll stay (or come back) but if it's not they won't. And that IMHO is how it should be.

Cccddd

Quote from: Peter Duggan on January 08, 2005, 02:03:31 PM
1. When I suggested 'the choice for everything', I was thinking of an admin option to apply this to either site links or all links as well as a user profile option.

oh thats a good idea. I mean sure the user already has the ability to do it other ways but the idea of making it a profile option to make it easier is a good thought. its a very small feature. i think since its so small it really would be better as a feature than a mod.

City Builder

Has someone packaged this into a mod or was it just let go?  It's nice to have the iurl but like some others I'd rather have it available just for admins and mods.  My thought is purely that internal links opening in a new window annoys me and my board users and people have grown accustomed to external links opening in new windows but most ask that when they reference another post on my board that it should open in the same window.

So is this a mod somewhere?

ryanbsoftware

how about this instead, have it customizable like this:

[url=http://forum.site.com/index.php?topic=1634.0|Tragret=_balnk]Thread[/url]

or

[url=http://forum.site.com/index.php?topic=1634.0|Tragret=_self]Thread[/url]

but if you just typed

[url=http://forum.site.com/index.php?topic=1634.0]Thread[/url]

the admin could set the target that would be used. ;D

Advertisement: