Recent Topics

1 Nov 20, 2005 02:25    

Hi Everyone!

Where do I have to edit the code in order the links of the linkblog showed in the template "custom" open in a new window?

I know I have to add target="_blank" but where?

Here is the address of my blog:
http://france-japon.net/blog/

Thanks for your kind help.

2 Nov 20, 2005 04:39

http://forums.b2evolution.net/viewtopic.php?t=2254

Or use the forum search. This question has been asked quite a bit. And I'll add in my opinion as I usually do when I answer this question: I think you should trust your users to use the back button to return to your site if you want to. I'm usually annoyed when a site opens new windows.

3 Nov 20, 2005 05:47

Thanks. It was very helpful! It works!
The solution of the checkbox is interesting. I'll try it for a while.

personman wrote:

http://forums.b2evolution.net/viewtopic.php?t=2254

Or use the forum search. This question has been asked quite a bit. And I'll add in my opinion as I usually do when I answer this question: I think you should trust your users to use the back button to return to your site if you want to. I'm usually annoyed when a site opens new windows.

4 Oct 10, 2006 07:14

OK, I have done a search and come up empty. The link provided earlier in this post as well as my results of my search only address a "blanket" approach to opening a link in a new window.

I only want a link in the Linkblog list to open in a new window. If I use the javascript option as posted in th elink above, it captures all links on my page. I don't want my blog list links to open in a new window, only links to other sites listed in my linkblog.

So, I ask the original question of this post again. How/where do you change the code so that links listed via the linkblog ONLY open in a new window?

Thank you.

5 Oct 10, 2006 14:21

Here's an option. Instead of putting the url of your linkblog posts in the "link to url" field, just put a link in the body of the post and leave the title blank. Then you can add target="_blank" to some of the links if you like.

6 Oct 10, 2006 15:44

Thanks for the option, but I would like to use the linkBlog as constructed by the script, with the exception of opening in a new window.

This morning, I checked my SQL database, and the links are just stored as URL, and not the actual <A href=""> string definition. So that means somewhere when the linkBlog list is generated, it creates the <A> tag for that link. That is the section I am looking for.

If I could find that, I think I can resolve my issue. Thanks!

7 Oct 10, 2006 15:48

/skins/<skin name>/_linkblog.php (or /skins/_linkblog.php if your skin just includes the default), but I agree with Dan, any site that starts spawning new windows without me asking I just close ;)

¥

8 Oct 10, 2006 15:53

I see. Actually, there isn't special code for generating a linkblog title/link. /skins/_linkblog.php uses the $Item->title() method, which comes from /inc/MODEL/items/_item.class.php (line 1941). Line 1961 looks like this:

        $title = '<a href="'.$this->url.'">'.$title.'</a>';


You could change that, but if you use the link to url field in any normal posts, they'll load in new windows, too.

9 Oct 10, 2006 15:55

I've looked at that file, but I don't see anywhere in it where it constructs the <A> link tag:


// Load the linkblog blog:
$LinkblogList = & new ItemList(
	$linkblog, array(), '', '', '', $linkblog_cat, $linkblog_catsel, '', 'ASC',
	'main_cat_ID title', $linkblog_limit, '', '', '', '', '', '', '',
	'posts', $timestamp_min, $timestamp_max );
...

while( $Item = $LinkblogList->get_category_group() )
{
	// Open new cat:
	//echo $linkblog_catname_before;
	//$Item->main_category();
	//echo $linkblog_catname_after;

	while( $Item = $LinkblogList->get_item() )
	{
		echo $linkblog_item_before;
		$Item->title();
		echo ' ';
		$Item->content( 1, 0, T_('more'), '[', ']' );	// Description + more link
		echo ' ';
		//$Item->permanent_link( '#icon#' );
		echo $linkblog_item_after;
	}

	// Close cat
	//echo $linkblog_catlist_end;
}
// Close the global list
echo $linkblog_main_end;

I am figuring that the call to either $Item->title(); or $Item->content(); does it. So, I guess, that is what I am looking for. Or is it in the linkblog array object constructor? Which leads me to, once again, where is that located?

Thanks.

10 Oct 10, 2006 15:55

personman wrote:

I see. Actually, there isn't special code for generating a linkblog title/link. /skins/_linkblog.php uses the $Item->title() method, which comes from /inc/MODEL/items/_item.class.php (line 1941). Line 1961 looks like this:

        $title = '<a href="'.$this->url.'">'.$title.'</a>';


You could change that, but if you use the link to url field in any normal posts, they'll load in new windows, too.

THANK YOU!!! That is what I am looking for! I appreciate it!

11 Oct 10, 2006 16:12

Not being to up on the ins and outs of PHP and CSS, I just had an idea. Is there a CSS constructor that allows me to apply a target parameter to an <A> tag?

For example, the following code places an '(' and ')' before and after a link:


.bTitleRight a:before {	content: ' ( '; }
.bTitleRight a:after {	content: ' ) '; }

Is there something like:


.bLinkUrl a:target { content: '_blank' }

12 Oct 10, 2006 16:19

No, that's a bit beyond the scope of what css is meant to do. I suppose you could do that in JavaScript, but there are 20 reasons why that's a bad idea.

You could modify _linkblog.php to use something other than $Item->title(). Give me five minutes and I'll see if I can whip something up.

13 Oct 10, 2006 16:25

Thanks. Yeah, I was going down that path right now after I looked around and found out CSS couldn't really do that.

I was thinking of taking what is returned from the $Item->title() method and assigning it to a variable. Then use str_replace to replace the first part of the string with a target element added. Then echo the variable result.

Is this possible? can the result of the $Item->title method be assigned to a variable such as:


$tmpvar = $Item->title() ;
echo str_replace("<a href=", "<a target='_blank' href=",$tmpvar);

14 Oct 10, 2006 16:54

Got it to work!!! Here is my code I added to _linkblog.php:


function callback($buffer)
{
  return (str_replace("<a href=","<a target='linkwin' href=", $buffer));
}

...

ob_start("callback");
$Item->title();
ob_end_flush();

Thanks to all for your help in this!

15 Oct 10, 2006 17:13

Nicely done. Here's the way I came up with, which doesn't require using the output buffer:


//$Item->title();
echo '<a href="'. $Item->url . '" target="_blank">';
$Item->title('', '', false);
echo '</a>';


Whatever works, though.

16 Feb 17, 2007 23:17

Hmm,

I´m a little bit lost. I have a linkblog, too, but I´m not using the linkblog-in-sidebar function, because I have too much links for that.

I´ve searched the whole forum, found several topics, but not the simple solution I am looking for...

What I really want to have is simply the target="_blank" function for the linkblog headlines (in the main section) which open currently the links in the same window... nothing more, but nothing less.

There must be some place in the huge coding of the b2evo script, where the linkblog posting title will be generated with the corresponding URL and then displayed... there I want to integrate target="_blank"... but where?

Thanks for your help...
Daniel

17 Feb 17, 2007 23:38

Try this. Open up _main.php and find the part that displays the title. It will look like this:

		<h3 class="bTitle"><?php $Item->title(); ?></h3>


Change it to this:

		<h3 class="bTitle"><?php 
		if ($blog == 4) {
		   echo $Item->url_link('', '', $Item->title, array('target' => '_blank'));
		} else {
		  $Item->title(); 
		}
		?></h3>


That assumes that your linkblog is blog 4. If not, change the 4 to the id of your linkblog.

Btw, the doc page I consulted is [url=http://doc.b2evolution.net/v-1-9/evocore/Item.html#methodurl_link]here[/url]. Take a look at that to see what all is possible.

18 Feb 18, 2007 11:42

GREAT... exactly what I was searching for... thank you very much.

But I have still a small problem... I tried to extended the code as follows for the opening links in new windows from the display-all blog (n°1) and my linkblog (n°3):

<h3 class="bTitle"><?php  
    if ($blog == 1) { 
    echo $Item->url_link('', '', $Item->title, array('target' => '_blank')); 
    } elseif ($blog == 3) { 
    echo $Item->url_link('', '', $Item->title, array('target' => '_blank')); 
    } else { 
    $Item->title();  
    } 
?></h3>

Everything works this way for my linkblog (n°3), my newsblog (n°2) and the poping links in my all-in-one blog (n°1); [u]but[/u]... in the blog 1 not the headlines with no link behind them (from blog n°2) are gone....

That´s not ok...

By replacing $Item->title for blog 1 with $Item->title() gets back all headlines correcty, but the links are opening in the same window instead of _blank ones...

 <h3 class="bTitle"><?php  
     if ($blog == 1) { 
     echo $Item->url_link('', '', $Item->title(), array('target' => '_blank')); 
     } elseif ($blog == 3) { 
     ...



Any ideas for a blog 1 solution, too?

19 Feb 18, 2007 17:46

h3 class="bTitle"><?php  
    if (($blog == 1 or $blog == 3) and !empty($Item->url) ) {            
      echo $Item->url_link('', '', $Item->title, array('target' => '_blank')); 
    } else { 
      $Item->title();  
    } 
?></h3> 

That should do it.

20 Feb 18, 2007 21:42

Perfect, that´s exactly what my blog needed... you are a hero, personman! :D

21 Feb 18, 2007 21:44

Great, I'm glad it worked. :D

22 Feb 27, 2007 21:38

personman wrote:

h3 class="bTitle"><?php  
    if (($blog == 1 or $blog == 3) and !empty($Item->url) ) {            
      echo $Item->url_link('', '', $Item->title, array('target' => '_blank')); 
    } else { 
      $Item->title();  
    } 
?></h3> 

That should do it.

And... uhmmm... what about discriminating link codes by blog type? Is it possible?

I'm thinking of replacing the conditional with, dunno, "if ($blog{type} == 'linkblog')". So, you don't have to change the code every time you add or delete a blog.

I'm just making it up, I just wanna know if something like that's possible. If it is not, it would be a great addition for the next version of b2evo... :)

Cheers,
Sebastián

23 Mar 17, 2008 22:40

Hi,
I am using the newest version of b2evolution and can't seem to find the same lines of code your using for this solution. I found this part in the _linkblog.widget.php.

	function get_name()
	{
		$title = T_('Linkblog');
		
		return $title;
	}

Is this where I would make my changes, so that it opens in a new window. I've seen this forum post, but I don't want my users to have to click on a checkbox, I'd like only for the linkblog to open new windows. Thanks a lot for any help you can offer.

24 Mar 27, 2008 20:55

this is how i figured out how to open only certain links in a new window...

i'm a really big newbie when it comes to this stuff, so hopefully this helps someone else who was wondering the same thing.

Drop this at the bottom of your index.main.php page and modify the url you want to popup in it's own window:


<script language="JavaScript">

 for (var i=0; i<=(document.links.length-1); i++)
   {
   if(document.links[i]=="THE URL THAT YOU WANT IN NEW WINDOW"){
	   document.links[i].target = "_blank";
	   }
   }

</script>

I'm sure their is a better way to do this, but I didnt really understand the above posts. hope this helps.


Form is loading...