Recent Topics

1 May 20, 2007 12:53    

My b2evolution Version: Not Entered

How to do insert links in Blog post so that the link will open in a new window rather then having people click links in my Blog post that take them away from the Blog!

Thanks,

2 May 20, 2007 14:00

You have to have <a href="..." target="_blank"> in each link. Not sure how you add it though.

3 May 20, 2007 14:13

I will try to add the extra code. I think I have tried it before and it did not work.

I think this should be a standard feature in the software to add a link that opens a new window or the same window. It would be much easier!

Thanks for your reply!

4 May 20, 2007 17:13

There are many threads about this topic, but in general forcing a new window is considered rude. Used to be anyway. Now the way I browse all links will always open new tabs unless it's a link in the same domain, but I digress. When you make a link using the "link" button you'll see the code it makes, so simply add [ target="_blank" ] to it. I should be able to find the file you can edit to make it happen automagically, but not now because I'm tired.

Anyway it's possible but it would be a lousy feature. Nothing personal, but who are you to say I can't surf away from your web? Sometimes I'll click a link and immediately close the tab I was on because I'm done with that page. If it's your page, well, that's life eh?

5 May 20, 2007 17:23

I have begun editing my post with the new code. I think it is rude too. Nonetheless, most of my articles have links throughout them. I would rather not direct people away from my blog in the middle of an article.

I think this way it will be easier for people to not have to find their way back to where they were in the article.

I will see what people think.

Thanks man!

6 May 20, 2007 23:46

Open up plugins/_quicktags.plugin.php and find the function that makes the link button work, then change it a bit. While you're adding the target->blank bit I'll bet you wished your links had title="something" in them right?

		function b2evoInsertLink(myField, i, defaultValue) {
			if (!defaultValue) {
				defaultValue = 'http://';
			}
			if (!b2evoCheckOpenTags(i)) {
				var URL = prompt('<?php echo T_('URL') ?>:' ,defaultValue);
				if (URL) {
					var URLTITLE = prompt('<?php echo T_('TITLE') ?>: ' ,URL);
					b2evoButtons[i].tagStart = '<a href="' + URL + '" title="' + URLTITLE + '" target="_blank">';
					b2evoInsertTag(myField, i);
				}
			}
			else {
				b2evoInsertTag(myField, i);
			}
		}


This will make the title attribute start as the site you're linking to and give you the option to change it. It will always add the target->blank bit. With a bit of creativity you could make the title be something like "link opens in new tab or window".

		function b2evoInsertLink(myField, i, defaultValue) {
			if (!defaultValue) {
				defaultValue = 'http://';
			}
			if (!b2evoCheckOpenTags(i)) {
				var URL = prompt('<?php echo T_('URL') ?>:' ,defaultValue);
				if (URL) {
					defaultTitle = 'link opens in new tab or window';
					var URLTITLE = prompt('<?php echo T_('TITLE') ?>: ' ,defaultTitle);
					b2evoButtons[i].tagStart = '<a href="' + URL + '" title="' + URLTITLE + '" target="_blank">';
					b2evoInsertTag(myField, i);
				}
			}
			else {
				b2evoInsertTag(myField, i);
			}
		}

If a fella was even more creative you would have the option of not using the target->blank bit, but since that's your goal and I'm not a more creative fella this will have to do.

Hope it works, and if not let me know what went wrong. As always, backup your file(s) before hacking because I test stuff by saying "here try this" to people ;)

7 May 20, 2007 23:51

Thank you my friend, I will check it out!


Form is loading...