Is it possible to have set outgoing links to open in new window?

Comments

designerbrent’s picture

gumdrop,

Try this in your tpl file:

<a href="<?php print $leech_news_item->link ?>" target="_blank" title="<?php print $title ?>"><?php print $title ?></a>

Brent

designerbrent’s picture

Status: Active » Fixed
PCanzona’s picture

In the Garland theme, exactly which tpl file would you add this to?

Pete

designerbrent’s picture

that should go in your node.tpl.php file if memory serves me correctly.

PCanzona’s picture

Hi, here's the code from Garland's node.tpl.php file:

phptemplate_comment_wrapper(NULL, $node->type);

print $node->nid; " class="node if ($sticky) { print ' sticky'; } if (!$status) { print ' node-unpublished'; } ">

print $picture

if ($page == 0):

print $node_url " title=" print $title "> print $title

endif;

if ($submitted):
print t('!date — !username', array('!username' => theme('username', $node), '!date' => format_date($node->created)));
endif;

print $content
if ($taxonomy):
print $terms

endif;

if ($links):

endif;

Where exactly would I place " print $leech_news_item->link " target="_blank" title=" print $title "> print $title " to make it work? I've tried several places already.

Thanks much,

Pete

designerbrent’s picture

Pete,

If you are modifying Garland just for your Leech theme this will be fine.

Replace line 8 of node.tpl.php with the following:

<h2><a href="<?php print $leech_news_item->link ?>" target="_blank" title="<?php print $title ?>"><?php print $title ?></a></h2>

Cheers,
Brent

PCanzona’s picture

Hi Brent,

I replaced line 8 in node.tpl.php with your code and, for some reason, the link is still opening up in the same window or tab (in I.E. and Firefox, respectively). Any ideas why this could be? I really don't want users redirected away from the site.

Thanks for all your time.

Pete

designerbrent’s picture

Pete,

My guess is that you may be trying a different link? This snippit will change the title link on the teaser view of the item, not the link list at the bottom of each node. (I'm not sure how to change those links, sorry!)

Cheers,
Brent

PCanzona’s picture

Hi Brent, Yes you are right: The header link works perfectly now (opens in a different window/tab). Is there a way to suppress the display of the "read original article" link in the teaser list?

Thanks so much,

Pete

designerbrent’s picture

I haven't played with the module that far, but the obivious way is to comment out the 'print $links; ' line.

Good luck.

Brent

dries’s picture

Status: Fixed » Closed (fixed)