miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /  
 

Making urls open in the same window: _top

 
Author MKJ
Partaker
#1 | Posted: 29 Jun 2006 09:14 
I am using the minibb forums to link to various sections of my site and would like to make all the urls open in the same window instead of a new window. These urls are being entered in the topics. Where can I find the code that controls this?

Author Paul
Lead Developer 
#2 | Posted: 29 Jun 2006 11:11 
bb_func_txt.php: urlMaker()

bb_codes.php: encodeBB(), decodeBB()

replace "_blank" targets...

Or it's better to duplicate URL code and create additionally new code which will not open URL in new window. Something like [urls=....][/urls]

Author Bluesplayer
Partaker
#3 | Posted: 11 Mar 2008 04:19 
Hi Paul

The above doesn't seem to work on the new forum I have just installed. What else do I need to do?

Author Paul
Lead Developer 
#4 | Posted: 11 Mar 2008 10:37 
What exactly doesn't work? I see that your links are still opened in _blank target. So either you have improperly replaced this tag, either wrongly developed the new BB code... I don't know.

Author Bluesplayer
Partaker
#5 | Posted: 11 Mar 2008 10:44 
Oops. It does work. I just realized that I had to alter the posts already made in the database or redo them for the alteration to take effect.

I am using this forum just to link to sections of my site internally so I didn't want new windows all over the place. Sorted now though with the above code changes.

Cheers

Author Paul
Lead Developer 
#6 | Posted: 12 Mar 2008 05:31 
Of course you will need to update the database manually... replacing "_blank" to "_top"... for example

update minibbtable_posts set post_text=REPLACE(post_text,'"_blank"','"_top"') where POSITION('"_blank"' IN post_text)>0;
or something like this...

Author Bluesplayer
Partaker
#7 | Posted: 25 Nov 2008 04:11 
Hi Paul

I came across this code:

function formatLinks() {
var fileLink;
if (document.getElementById('ContentBody') && document.getElementById('ContentBody').getElementsByTagName('a')) {
for (var i = 0; fileLink = document.getElementById('ContentBody').getElementsByTagName('a')[i]; i++) {
if (fileLink.href.match(/^(http|https)/) && (fileLink.href.indexOf(location.hostname) == -1)) {
fileLink.setAttribute('target', '_blank');
}
}
}
}

var oldonload = window.onload;
if (typeof window.onload != 'function') { window.onload = function() { formatLinks(); }; }
else {
window.onload = function() {
if (oldonload) { oldonload(); }
formatLinks();
}
}
This would be ideal for my use as I am referring to content on my shopping forum and off it. Internal links don't need a new window but offsite do. The above code is able to do that but needs adjusting for minibb. Bit beyond me. Are you able to use it or adjust it?

Regards

Edit: Come to think of it I could write a new tag couldn't I for this?

Author Paul
Lead Developer 
#8 | Posted: 25 Nov 2008 04:58 
Bluesplayer
I don't understand how your code is related to this topic. It's pure JavaScript, we are talking here about PHP things.

I guess, yes it's possible just to program separate BB codes for URLs which begin with your own domain, or begins with any other domain, and they will use different target attributes. Example of BB codes containing your own URL only, are located here.

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /
 Making urls open in the same window: _top
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Check out the File and Picture Attachments add-on: extend your miniBB-forums, attaching images and files.


  ⇑