miniBB ®
 
miniBB Community Forum
 | Forums | File Bank | Sign Up | Reply | Search | Statistics | Manual |
Photo album addon for miniBB Attract your miniBB-community, letting members publish their own photos with the Photo album add-on!
Custom Tutorials and Modifications miniBB Community Forum / Custom Tutorials and Modifications /
Short link for this topic:

Making urls open in the same window: _top

Author MKJ
Forums Member
#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
CEO
#2 | Posted: 29 Jun 2006 11:11 | Edited by: Paul
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
Forums Member
#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
CEO
#4 | Posted: 11 Mar 2008 10:37 | Edited by: Paul
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
Forums Member
#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
CEO
#6 | Posted: 12 Mar 2008 05:31 | Edited by: Paul
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
Forums Member
#7 | Posted: 25 Nov 2008 04:11 | Edited by: Bluesplayer
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
CEO
#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 Community Forum / Custom Tutorials and Modifications / Making urls open in the same window: _top Top
Your Reply Click this icon to move up to the quoted message

» Username  » Password 
You are welcome to post anonymously by entering a nickname with no password (if that nickname has not been taken by another member) or by leaving both fields empty. If you have a forums membership account, you can also sign in from this page without posting a message, or sign in and post at once.


Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.

 
miniBB Community Forum Powered by Free Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contacts